• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

fdisk: Unable to write /dev/sdg: Bad file descriptor – error while formatting USB disk

by admin

Problem

While formatting a USB disk which was mounted in write-protected mode we are getting the below error:

fdisk: Unable to write /dev/sdg: Bad file descriptor

Solution

1. The disk in this example is /dev/sxx. Disable read-only mode on the USB disk first. Make sure hdparm is installed, then run the following command:

# hdparm -r0 /dev/sxx

2. Make sure the util-linux package is installed, and then wipe out the file system.

# wipefs --all /dev/sxx --force

3. Make a new parttion on the disk using fdisk:

# fdisk -cu /dev/sxx

then ‘d‘ to delete and ‘w‘ to write.

4. The disk is now ready to be formatted. To format the disk with the ext4 file system, the following command can be used:

# mkfs.ext4 /dev/sxx

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. lastb: command not found
  2. debugfs: command not found
  3. chown: command not found
  4. CentOS / RHEL 5, 6 : how to disable NetworkManager
  5. How to Reduce an LVM volume on Ubuntu
  6. whois Command Examples in Linux
  7. How to edit Virtual Machine Hardware in RedHat Virtualization
  8. unzip: command not found
  9. How to use wget to download file via proxy
  10. How to monitor NVME drives on Centos 6

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright