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
• 25,090 points
127 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
• 56,540 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
989 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,030 points
379 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
708 views
0 votes
2 answers

how to loop through the content of a file using bash

#!/bin/bash for i in  `cat peptides.txt` do echo $i done READ MORE

answered Sep 4 in Linux Administration by Prakash K. Aithal
683 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
185 views
+6 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
2,354 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
668 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
• 56,540 points
92 views
0 votes
1 answer

How to check permissions of a file in the Linux system?

Hi@akhtar, If you prefer using the command line, ...READ MORE

answered Aug 13 in Linux Administration by MD
• 56,540 points
70 views