2

I'm using Raspbian, and after some uptime (less than an hour) the root filesystem suddenly becomes readonly. Here is a console log of checking whether the SD card write protection is turned on, and trying to remount the filesystem with read-write access:

pi@raspberrypi:~$ touch asd
touch: cannot touch `asd': Read-only file system
pi@raspberrypi:~$ sudo ./sdtool-rpi /dev/mmcblk0 status                                                                                                                 
[+] Found RCA for /dev/mmcblk0: AAAA.
[+] Card CSD: 400E005A5B5900003B377F800A404079.
[+] Write protection state: Off.
pi@raspberrypi:~$ sudo mount -o remount,rw /
mount: cannot remount block device /dev/mmcblk0p2 read-write, is write-protected
pi@raspberrypi:~$ 

After a reboot everything is back to normal for some time. How could I solve this problem? Could this be a dead SD card?

  • sdtool-rpi does not seem to be standard package. Are you doing something to access the SDcard? – Milliways Nov 18 '15 at 0:48
  • As I said after a reboot everything is functioning normally for some time. I used wget to download sdtool-rpi. – laci37 Nov 18 '15 at 12:55
  • If you're still an active user, paste the last 500 lines of dmesg into your answer. – PNDA Jan 21 '16 at 15:35
0

Do a mount command on its own - you will possibly find your root partition is marked, in the last group of words (in side parentheses like these), something beginning with (ro,...) whereas you would expect it to be (rw,...)! This is highly likely to mean that a file system error was detected and the standard kernel behaviour in this case (for a faulty FS) is to mark the file-system READ-ONLY to prevent further "corruption" {you may actually see the setting for that as the option errors=remount-ro in the same area of the output from mount on other actual file-systems}.

An, ahem, "not suitable", Flash card is one possible cause of this type of error - though I venture to suggest it is not the only one! For example, even with journalled file-system types such as Ext4, it is not a good idea to remove power from a *nix system without flushing any pending writes out to the file-system - this is one of the steps that the shutdown command will do as appropriate (I wanted to quote the *nix man page for shutdown(8) to point out the -n option which in the past said something like:

-n - bring the system down, quickly, by ourself - the system unit is ON FIRE!

but the standard text now just says it is "discouraged" to use that option. 8-P )

Recovery of the root partition is a bit more fraught than other cases because the fix requires running fsck on the file-system which needs to be (IIRC must be) not mounted at the time. If you have a PC with a card reader and a Linux installation there it is easiest to use that to repair the SD card - (Try and prevent the SD card from being automatically mounted when you insert it into the PC as you´ĺl only have to un-mount it to do the same fsck on it!) - once you have identified the added "disk" in your PC has the faulty partition/file-system.

  • Probably a corrupted fs was the problem, I reflashed the SD card, and now it works. – laci37 Jan 25 '16 at 9:27
  • I have similar issue, and I tried several tools already even on mac and windows and nothing helped, it still says that the sdCard is read only. – Pini Cheyni Jul 13 '17 at 10:13
  • 1
    Ah, but Windows only sees the first partition on SDCards and that is usually a FAT one which isn't the partition/file-system that is used for / in Linux... A Mac might detect all the partitions but it might not show them in its fancy GUI - I am not terribly familiar with that OS... – SlySven Oct 31 '17 at 8:28
1

Long story short and based on the console output you provided, your SD card might be broken. I have an SD card that does exactly this.

If that's not the case, have you checked for anything that might remount the system as read-only?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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