Write-Protected File System
Greetings. My flash that contains my debian OS suddenly became "read-only" after a power failure. I booted with another OS disk and tried to fsck the flash drive; however this message appears: "disk write-protected; use the -n option to do a read only check".
I can run fsck with the -n option, but I need to repair the device and make it unprotected again. I have even tried to mkfs the device, but cannot because of the write-protected status. Thanks in advance. |
Does the drive contain a physical read-only switch? I know some flash cards have that.
|
No, this one does not have a switch. From what I can tell, Linux will put a partition into "write protected" mode when it detects file inconsistencies.
|
Can you please post the entire output from the fsck command?
I would suggest that if the data on the flash disk is important to you, before anything else you make a byte-for-byte backup of the filesystem onto another device in case any of your subsequent recovery efforts go awry. |
Below is the output:
Quote:
|
Are you sure that /dev/sdc5 is the Debian o/s filesystem in question? A blkid should confirm it (consider label, size etc.).
Also check that the filesystem is actually unmounted and not being auto mounted by your other o/s disk by issuing a mount | grep sdc5 command. To see what fdisk thinks of the flash, could you also throw a fdisk -l /dev/sdc at it? |
I confirmed that the disk is not mounted. The results of the other commands are below:
blkid Quote:
Code:
Disk /dev/sdc: 7.5 GiB, 8004304896 bytes, 15633408 sectors |
That looks fine to me. So what happens when you try to mount the filesystem? (mount -t ext4 -v -o rw /dev/sdc5 mountpoint [change mountpoint to your desired mount point]).
It's a bit unusual that your original fsck command tried to use fsck.ext3 rather than fsck.ext4. What command did you issue? |
mount -t ext4 -v -o rw /dev/sdc5 /mnt
Quote:
I used fsck. Now when I use fsck it uses fsck.ext4 with the same results. I don't have an explanation of why it used ext3 before. |
Ok. Filesystem corruption looks the most likely reason, I'm afraid to say.
What does fsck.ext4 with the -n option give you? If it looks too bad, you'll probably need to start looking at recovery software such as testdisk (if the data is important to you). If the data isn't important to you, you can always reformat the relevant partition(s) and reload your operating system. That's assuming you don't have a backup image somewhere. |
fsck with -n is below:
/dev/sdc5: clean, 109061/439776 files, 1753081/1758976 blocks mkfs won't let me proceed because it is write-protected. Doesn't this imply that the problem is not corrupted file system? |
Quote:
Have you tried hdparm -r0 /dev/sdc ? |
I would not expect a power failure to damage the drive and it could be a coincidence but it could of failed. As stated I would copy anything important off the drive as soon as possible. Can you mount the drive read only?
Flash drives do fail and in several ways. Be lucky that it failed read only and not completely dead. |
Obviously, "computers don't 'just decide' to do these things." Look at the output of the dmesg command, which displays the swirl of messages that occur at boot, and I predict that you will discover that a file-system integrity check failed. Therefore, the disk was mounted read-only.
|
Also, what is the make/model of the drive? How is it connected to your computer (e.g. SATA, USB, etc)?
|
All times are GMT -5. The time now is 06:34 AM. |