Unable to open /dev/sdb read-write (Read-only file system)
Solution 1
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.
Solution 2
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:
Solution 3
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)
Related videos on Youtube
AzkerM
A networking professional building elegant resorts in the romantic island of Maldives, while assisting to choose the best out of technologies. A Tech Enthusiastic who's fascinated about Technology, Networking, Security and Open-Source platforms. A self learner who loves ethical hacking and Linux distro's. I founded GeekLK, a tech blog where technological challenges are explained in simple English. Ask Ubuntu is where I roam the most out of all SE's. "Beware of JEALOUSY, for verily it destroys good deeds the way FIRE destroys wood" ~ Prophet Muhammadh S.A.W (PBUH)
Updated on September 18, 2022Comments
-
AzkerM over 1 year
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?
-
yjwong over 10 yearsWhat is the storage device? If it's a USB stick or an SD card, there may be a write-protect switch...
-
AzkerM over 10 yearsWell its a USB stick (SanDisk) & no it does not have a switch.
-
AzkerM over 10 yearsnone of those did worked..
-
-
AzkerM over 10 yearsPartition is unmounted and the
/path/to/target
is root who's holding permission, also I'm executing this with root. -
AzkerM over 10 yearsyes root does have permission to write and I tried all the possible ways and tools to get this thing fixed.. but no luck
-
AzkerM over 10 yearsI 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 about 10 yearsI 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.
-
JHS over 5 yearsWow, I'm glad you mentioned this before I spent more time with partitioning tools. Thank you - solved my issue.
-
devasia2112 about 5 yearsmy 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.
-
Sandburg over 4 yearsSanDisk and some noname seem to have the protection you metioned. I detected a faulty sector on my micro SD.
-
s1n7ax over 4 years[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
-
geneorama over 3 yearsThank you @WebFreak001 for adding the image!
-
Kaushal Bhatol almost 3 yearsSam issue with my USB drive and now, I think my USB commits suicide due to repeated formatted.. I am giving him peace now...
-
user3330273 over 2 yearsI cannot believe I spent 2+ hours this morning trying to fix this problem when it was an unfixable problem with my SanDisk Ultra all along!
-
Krishna over 2 yearsThanks.. I was getting mad over this issue..