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, 2020 in Linux Administration by akhtar
• 38,230 points
1,633 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, 2020 by MD
• 95,440 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
5,056 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,210 points
2,096 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
1,869 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 5, 2020 in Linux Administration by Prakash K. Aithal
2,503 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
966 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 19, 2018 in Career Counselling by eatcodesleeprepeat
• 4,710 points
10,311 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,890 points
2,192 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, 2020 in Linux Administration by MD
• 95,440 points
2,368 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, 2020 in Linux Administration by MD
• 95,440 points
1,484 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP