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

0 votes

Hi Guys,

I am trying to format my USB disk, but it shows me the below error.

fdisk: Unable to write /dev/sdg: Bad file descriptor
May 11 in Linux Administration by akhtar
• 11,250 points
26 views

1 answer to this question.

0 votes

Hi@akhtar,

You may get this error if your disk has only read only mode. You have to disable read-only mode on the USB disk first. Now follow the below given steps.

  • Make sure hdparm is installed, then run the following command.

$ hdparm -r0 /dev/sxx
  • Install the util-linux package and then wipe out the file system.

$ wipefs --all /dev/sxx --force
  • Make a new partition on the disk using fdisk:
$ fdisk -cu /dev/sxx

then ‘d‘ to delete and ‘w‘ to write.
  • 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

Hope this will solve your error.

answered May 11 by MD
• 24,500 points

Related Questions In Linux Administration

0 votes
1 answer

How to display a simple list of all disks, like this /dev/sda /dev/sdb ?

You can list all the disk in ...READ MORE

answered Jul 12, 2018 in Linux Administration by DearestOne
• 200 points
381 views
–1 vote
1 answer

How to get octal file permission in linux?

You can use this: stat -c "%a %n" ...READ MORE

answered Jan 3, 2019 in Linux Administration by Omkar
• 69,060 points
258 views
0 votes
1 answer

Not able to access /etc/sudoers.d/python file

I think your system is not allowing ...READ MORE

answered Feb 6, 2019 in Linux Administration by Lohit
515 views
0 votes
1 answer

how to loop through the content of a file using bash

One of the ways to do it ...READ MORE

answered Feb 15, 2019 in Linux Administration by ajs3033
• 7,280 points
375 views
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
144 views
+5 votes
17 answers

What are job opportunities as a Linux System Administrator?

I just started working professionally as a ...READ MORE

answered Jul 18, 2018 in Career Counselling by eatcodesleeprepeat
• 4,750 points
1,448 views
0 votes
1 answer

setting a variable output from a bash command

You can use $(command), which in my ...READ MORE

answered Feb 15, 2019 in Linux Administration by DareDev
• 6,850 points
429 views
0 votes
1 answer

Unable to login with GUI on CentOS/RHEL

Hi@akhtar, For new installation of CentOS/RHEL, GUI doesn't ...READ MORE

answered May 11 in Linux Administration by MD
• 24,500 points
39 views
0 votes
1 answer

How to install python-poster in RedHat?

Hi@akhtar, To install python-poster in RedHat/CentOs, you can ...READ MORE

answered Feb 11 in Linux Administration by MD
• 24,500 points
75 views