As in the title, I'm unable to format it as it says read-only. I've tried couple of searches and the solutions too. Even I tried GParted to see I have any luck. Unfortunately below is what I get.

GParted 0.11.0 --enable-libparted-dmraid

Libparted 2.3

Delete /dev/sdb1 (fat32, 14.91 GiB) from /dev/sdb  00:00:00    ( ERROR )

calibrate /dev/sdb1  00:00:00    ( SUCCESS )

path: /dev/sdb1
start: 32
end: 31,266,815
size: 31,266,784 (14.91 GiB)
delete partition  00:00:00    ( ERROR )
libparted messages    ( INFO )

Unable to open /dev/sdb read-write (Read-only file system). /dev/sdb has been opened read-only.
Unable to open /dev/sdb read-write (Read-only file system). /dev/sdb has been opened read-only.
Unable to open /dev/sdb read-write (Read-only file system). /dev/sdb has been opened read-only.
Unable to open /dev/sdb read-write (Read-only file system). /dev/sdb has been opened read-only.
Unable to open /dev/sdb read-write (Read-only file system). /dev/sdb has been opened read-only.
Can't write to /dev/sdb, because it is opened read-only.
Unable to open /dev/sdb read-write (Read-only file system). /dev/sdb has been opened read-only.

Output of dmesg

[10061.878073] usb 2-1.3: new high-speed USB device number 8 using ehci_hcd
[10061.972140] scsi9 : usb-storage 2-1.3:1.0
[10062.969922] scsi 9:0:0:0: Direct-Access     SanDisk  Cruzer Blade     1.20 PQ: 0 ANSI: 5
[10062.971746] sd 9:0:0:0: Attached scsi generic sg2 type 0
[10062.972799] sd 9:0:0:0: [sdb] 31266816 512-byte logical blocks: (16.0 GB/14.9 GiB)
[10062.976439] sd 9:0:0:0: [sdb] Write Protect is on
[10062.976453] sd 9:0:0:0: [sdb] Mode Sense: 43 00 80 00
[10062.977353] sd 9:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[10062.999026]  sdb: sdb1
[10063.003367] sd 9:0:0:0: [sdb] Attached SCSI removable disk

Output of fsck

sudo fsck -n /dev/sdb
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
fsck.ext2: Device or resource busy while trying to open /dev/sdb
Filesystem mounted or opened exclusively by another program?

Output of sudo fdisk -l /dev/sdb

Disk /dev/sdb1: 16.0 GB, 16008593408 bytes
64 heads, 32 sectors/track, 15266 cylinders, total 31266784 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f20736b

This doesn't look like a partition table
Probably you selected the wrong device.

     Device Boot      Start         End      Blocks   Id  System
/dev/sdb1p1   ?   778135908  1919645538   570754815+  72  Unknown
/dev/sdb1p2   ?   168689522  2104717761   968014120   65  Novell Netware 386
/dev/sdb1p3   ?  1869881465  3805909656   968014096   79  Unknown
/dev/sdb1p4   ?  2885681152  2885736650       27749+   d  Unknown

Partition table entries are not in disk order

This is not yet fixed as I've tried plenty of ways. Any idea on how to fix this?

  • What is the storage device? If it's a USB stick or an SD card, there may be a write-protect switch... – yjwong Jan 23 '14 at 7:10
  • Well its a USB stick (SanDisk) & no it does not have a switch. – AzkerM Jan 23 '14 at 7:15
  • possible duplicate of USB turn write protection off, since [sdb] Write Protect is on – falconer Jan 29 '14 at 8:30
  • none of those did worked.. – AzkerM Jan 29 '14 at 8:50
  • Does it have anything on it? If not use gparted and create a new gpt partition table (not msdos, the default) I just had this problem on mine and that fixed it – user314033 Aug 9 '14 at 15:39

First try the command sudo hdparm -r0 /dev/sdb (method taken from another askubuntu answer). Then try remounting rw the partition. If these steps don't work then you are most likely out of luck with that pendrive.

Since the kernel says that the whole drive is write protected you have to deal with the protection at the drive level.

hdparm does this. If it can't solve this it is likely that your pendrive is write protected by design or it is failed.

Maybe it has a hardware switch under its casing if you take it apart. If it was writable before maybe this switch got flipped, if it was never writable maybe it was always on.

Also googling for your device gives out a lot of hits with the same problem even on windows. This is from the Sandisk forums:

For the SanDisk USB stick the answer has been posted many times. If new return it to where you bought it. If under warrantee return it to SanDisk. BOTH options will get you a new USB stick. There are no other consistent options.

Also from the Sandisk forum:

This is an offical answer if you contact customer service:

"I understand that you are getting write protection error while accessing your Cruzer flash drive. The flash drive has detected a potential fault and has become write protected to prevent data loss. There is no method to fix this. You will need to backup your data and replace the flash drive. Our team of developers is in combination with the OS developers looking into a solution to resolve this issue. Please note that only a minor percentage of users are experiencing the write protection issue and these are the customers posting on the internet to find a solution."

So likely there is no way to solve it.

  • I guess this is it for the USB drive. Thank you so much for such a valuable time to find and post a descriptive answer. Since there's no such way rather than getting a new one. – AzkerM Jan 29 '14 at 11:06
  • I do not remember what else I tried apart from these answers available to this question. But what I came across is the same similar to this answer. There is no way to fix than replacing it. – AzkerM Mar 12 '14 at 4:42
  • SanDisk and some noname seem to have the protection you metioned. I detected a faulty sector on my micro SD. – Sandburg Nov 16 '19 at 8:39
  • [Solved] I unplugged my pen drive while it's mounted (i forgot). then I replugged it and mounted it again. After that, I got this error when I tried to mount. This fixed that read only issue – s1n7ax Jan 12 '20 at 3:26
  • Sam issue with my USB drive and now, I think my USB commits suicide due to repeated formatted.. I am giving him peace now... – Kaushal Bhatol May 16 at 12:11

My problem is always that the little lock switch on the side of the SD card is moved to "lock". Yes, I mean the physical switch on the side of the SD card.

See this picture:

SD card labeled lock states

  • Wow, I'm glad you mentioned this before I spent more time with partitioning tools. Thank you - solved my issue. – JHS Nov 3 '18 at 17:00
  • Thank you @WebFreak001 for adding the image! – geneorama Feb 3 at 17:49

If you've not tried this, first unmount the partition which you want to format and then continue the further jobs.

To check the permission of the mount you can use:

ls -ld /path/to/target

If it's permission issue, to solve it could change the permissions with chmod or just change the ownership recursively, and this is what I've shown below:

sudo chown <username>:<groupname> -R /path/to/target

Now if you need, you may also set the permissions with chmod:

find /path/to/target -type f -execdir chmod 666 -Rv {} +

(which gives owner, group and the world RW permissions for all the files in the target.)

find /path/to/target -type d -execdir chmod 777 -Rv {} +

(which gives owner, group and the world RWX permissions for all the directories in the target.)

(use sudo chmod if the owner is root)

  • Partition is unmounted and the /path/to/target is root who's holding permission, also I'm executing this with root. – AzkerM Jan 23 '14 at 8:42
  • ..and does root have the permission to write? if not set RW permissions for the root or change the ownership to normal user and then format... – precise Jan 23 '14 at 8:45
  • yes root does have permission to write and I tried all the possible ways and tools to get this thing fixed.. but no luck – AzkerM Jan 23 '14 at 9:01
  • my usb sandisk 32gb with a broken fedora installed has the same issue, it's retired now. there is no fix to such a thing, the time spent to research a way to fix this kind of mess just do not worth.. buy a new one and problem solved. – devasia2112 Mar 12 '19 at 14:11

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