• 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. How to Stop/disable Firewalld on CentOS/RHEL 8
  2. How To Migrate Existing Iptables rules to Nftables In CentOS/RHEL 8
  3. How to use the ssh-keygen Command in Linux
  4. “su: Authentication failure” – in Docker
  5. DNS configuration file /etc/named.rfc1912.zones explained
  6. CentOS / RHEL 6 : How to force a NTP sync with the NTP server(s)
  7. How to remove unwanted entries in /etc/shadow file
  8. “530 Non-anonymous sessions must use encryption” – while using curl
  9. How to Create Yum Repository For System Packages Installation in CentOS/RHEL
  10. How to create LXC container using lxcbr0 and virbr0 in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright