Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I have a USB which is write protected:

dmesg | tail

[10098.126089] sd 7:0:0:0: [sdb] Write Protect is on
[10098.126098] sd 7:0:0:0: [sdb] Mode Sense: 23 00 80 00
[10098.126779] sd 7:0:0:0: [sdb] No Caching mode page present
[10098.126788] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[10098.131418] sd 7:0:0:0: [sdb] No Caching mode page present
[10098.131425] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[10098.133335]  sdb: sdb1
[10098.135509] sd 7:0:0:0: [sdb] No Caching mode page present
[10098.135515] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[10098.135521] sd 7:0:0:0: [sdb] Attached SCSI removable disk

So how can I turn the write protection off?

What I've tried

  1. Checked if it has a hardware switch - no
  2. Tried to format it on windows and on linux (via terminal too)
  3. Tried fdisk | chmod
  4. Tried to fix this with servel tools from the ubuntu software center
  5. Used Google and have seen about 10,000 discussions about this problem but they were never solved

Additional informations

fsck -n /dev/sdb1

fsck from util-linux 2.19.1
dosfsck 3.0.9, 31 Jan 2010, FAT32, LFN
There are differences between boot sector and its backup.
Differences: (offset:original/backup)
  Not automatically fixing this.
Free cluster summary wrong (968250 vs. really 911911)
Leaving file system unchanged.
/dev/sdb1: 50 files, 93653/1005564 clusters

fdisk -l

   Device  boot.   Start        End      Blocks   Id  System
/dev/sdb1            32     8060927     4030448    b  W95 FAT32

umount /dev/sdb1

mkfs -t vfat /dev/sdb1

mkfs.vfat 3.0.9 (31 Jan 2010)
mkfs.vfat: unable to open /dev/sdb1
share|improve this question
I can't format it because of write protection. – noob Feb 17 '12 at 17:21
@micha - what kind of USB device is it - obviously you've checked if it has a hardware switch? any errors if you attempt to mount it? sudo mount /dev/sdb1 -v ? – fossfreedom Feb 17 '12 at 18:00
micha, fair enough. Have you tried running efsck or used Ubuntu's Disk Utility to check the health status of the flash disk? If it was working fine & then stopped working all of a sudden there could be a hardware malfunction. – kingmilo Feb 18 '12 at 8:53
@kingmilo e2fsck : Bad magic number in super-block while trying to open /dev/sdb1 SuperBlock is not readable. – noob Feb 18 '12 at 16:42
@micha - very well, still doesn't mean it's not faulty though unfortunately. It's common for storage devices to appear to work normally when in fact they are faulty, just at a different stage of faulty. I think with all the activity on this question you should ask for small donations to replace the drive, it would be easier 😜 – kingmilo Feb 18 '12 at 17:34
up vote 38 down vote accepted

To turn off disk device`s write protect, we use the low level system utility hdparm like this:

sudo hdparm -r0 /dev/sdb

where we asume that /dev/sdb is the Physical disk device we're working on. If the device has partitions that are mounted as read-only, you should re-mount 'em as read-write in order to write data to them.

Hope that helps.

share|improve this answer
You are my hero. Where can I learn what happened after this magic magic magic command? – Marcos Modenesi Jul 1 '15 at 23:55
You can find the explanation by typing that command here > – bagustris Jul 19 '15 at 5:31
@bagustris thanks! – Marcos Modenesi Aug 14 '15 at 10:45
it shows readonly = 0 (off) but still i'm not able to write or format. – Apr 11 at 6:26

After researching your question it appears that this is a not-too-uncommon problem with certain brands of USB flash drives (some older Samsung, a Kingston model) that would essentially just "crap out" for no known reason. People had tried opening them and jumping two leads (maybe from a flaky switch?) to no avail. If you still have this drive and it's still in warranty I'd return it and get a replacement.

I hate to break the bad news to you =\ but it appears you're out of luck in this situation as everything I've read points to hardware failure.

Edit 05/27/2016: I experienced an issue personally with a flash drive flaking out on me recently. In my case, this was a Corsair Flash Voyager 128GB that started slowing down pretty drastically on me. While it didn't show the symptoms noted here, it occasionally would not mount and showed up as a "Silicon Power" device. This was a result of the drive having accrued a large amount of bad sectors and dropping into diagnostic/programming mode. Since this is one of my more popular answers and this also falls into the category of "failing flash drives," I figured I'd include it here for reference.

share|improve this answer
@admins:i wanna know whether this type of answers are allowed or not :) – Tachyons Feb 18 '12 at 15:57
@AboobackerMk If it is the answer, then it is the answer. :) – James Feb 18 '12 at 15:59
@Tachyons "whether this type of answers are allowed or not?" what is with people on stackexchange consistently trying to discredit other people's questions or answers? This answer is obviously a valid answer; for the reason jrg said. – GoProCameraByGoPro Apr 16 '15 at 3:05
@GoProCameraByGoPro that is 3 year old comment , my concern was not about quality of the answer . and jrg already replied to my question :-) – Tachyons Apr 16 '15 at 9:26
@Tachyons I'm doing my part to call the pretension here on stackexchange into question. If I had the data I would look at the trend of the demographic of people who do that and I could probably just ignore it, but for now I'll have to ask them questions as I see them. – GoProCameraByGoPro Apr 16 '15 at 17:26

using fdisk -l locate the drive, ie: /dev/sdc1


umount /dev/sdc1

Finally, reformat the flash-drive

sudo mkfs -t vfat /dev/sdc1

I found this quick and easy. Be sure to UNMOUNT the drive before trying to format.

share|improve this answer
sudo mkfs -t vfat /dev/sdc1 > most blog say this , but people say its not working , let see if it works . – One Zero Feb 18 '12 at 11:38
unmounted... but mkfs.vfat 3.0.9 (31 Jan 2010) mkfs.vfat: unable to open /dev/sdb1 – noob Feb 18 '12 at 16:20
it worked for me, just had to use -I to make it one big partition and instead of /dev/sdc1, /dev/sdc instead. – mchid Feb 3 '15 at 14:21

Insert memory stick and start gparted. Select it via the button at top right. It should be obvious if you are inspecting your memory stick (Size is a good clue). Select Partition--> unmount.

Select 'Device' at top, then 'Create Partition Table' and take the default, which is msdos.

Now you should be able to create a new partition and format it f32. If you can't, it's probably bust.


share|improve this answer
Partitions are not editable because of write protection. – noob Feb 20 '12 at 13:50

Know the drive name by typing

sudo fdisk -l

Then determine what permissions do you want to have. Apply those permisions by

sudo chmod [permisions] [device]

Did you try backing up all data and then completely reformatting the drive?

share|improve this answer
I'd down-vote if I could. That won't work, chmod also writes to the disk, and it can't, because it is write-protected. Besides, @mic "can't format it because of write protection". I see you answered before this info was available, but now you should consider to delete this answer. – JMCF125 Mar 23 '14 at 22:54

protected by Community Dec 8 '12 at 8:00

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.