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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. Working with Vim editor (Text Editor)
  2. What are the Types of DNS Servers
  3. dart: The tool for managing Dart projects
  4. ark: command not found
  5. dd: Convert and copy a file
  6. su: command not found
  7. ss: command not found
  8. dolt blame: Displays commit information for each row of a Dolt table
  9. at Command Examples in Linux
  10. Image optimization with webp

You May Also Like

Primary Sidebar

Recent Posts

  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples
  • “glab mr” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright