7

I'm the new owner of a Raspberry Pi and I'm having trouble with my file-system getting stuck in read-only mode after rebooting the device.

Here's the hardware I'm working with:

Pi: model B

PSU: Samsung GSIII charger 5A 1A

SD: Kingston 8GB (brand new)

input: basic USB keyboard and mouse

video: HDMI

I can install Raspbian using the NOOBS image just fine and once I'm in I can configure and install programs but after a reboot 90% of the time on boot up I get a warning about the file-system being read only and after I log into the shell I can't do any task that involves writing to a file. I can't even launch the desktop. I can run any shell programs I had installed before reboot. I'm rebooting only using the commands sudo reboot and sudo shutdown -h now. When shutting down I wait for the video to die and the light on the Pi to stop blinking before removing power. I've tried re-imaging the SD card many times and the first boot always works fine, sometimes it lets me reboot once or twice but it always has the same problem eventually. I have a moderate familiarity with Unix/Linux but this is my first attempt at using a Pi. Help!

2
  • 1
    Does the SD card have a read-only switch on it?
    – Jivings
    Commented Sep 4, 2013 at 17:32
  • Yes and I mercilessly toggled it for good measure. The card showed up as read-write accessible on my laptop, only the pi thought it was readonly.
    – Reid A
    Commented Sep 7, 2013 at 16:45

2 Answers 2

9

Have a look in /var/log/syslog and see if you can find some indication of why. If the filesystem is mounting read-only, the last thing in that file will be whatever happened when it was still read-write, since the system cannot log there otherwise. Which may or may not be helpful...

The kernel's own log is in memory, however, and does not require a writable filesystem to access. You can view it with:

dmesg | less

Have a look at that right after you reboot.

[Then based on that...]

From the pictures it would appear you have either root filesystem corruption or a bad SD card. Let's hope it's the former.

Re-flashing the whole image over and over is kind of a brute method and doesn't provide any clues about the problem. Instead, put the SD card into another linux system (you can use a liveCD), but don't mount it (or umount it if it automounts). Then, if the second partition on the card is /dev/sdb2:

e2fsck -p -c /dev/sdb2

The -p means repair automatically, the -c is check for bad blocks. You should see some output about the things being fixed. This doesn't guarantee everything will be fine, but as long as the corruption is not too extensive, you should be okay. Do a second run e2fsck -f; -f forces the check since this time it may be marked "clean". If that goes okay, the fs is as repaired as it is going to get.

Try booting that, and if it works, you are in luck. If not, try with another SD card to make sure yours is not defective.

When shutting down, give it a good 15-20 seconds after all activity has stopped before you pull the power. Quite a few people come here with fs corruption problems, evidently the pi is very sensitive this way.

11
  • What the **** I rebooted again and it works correctly now. I tried rebooting another time just in case and it's still working. I don't want to call this solved just yet but If I'm able to reboot/powercycle a consistently for a while I'll mark it solved.
    – Reid A
    Commented Sep 4, 2013 at 17:47
  • Just for the record I re-imaged at least 4 times and had the read-write problem so I feel I was thorough enough to justify this post.
    – Reid A
    Commented Sep 4, 2013 at 17:48
  • It happened again Here are some photos I took of the logs.
    – Reid A
    Commented Sep 4, 2013 at 18:44
  • @ReidA : Okay, have a look at what I added above.
    – goldilocks
    Commented Sep 4, 2013 at 19:07
  • 1
    @ReidA Yeah :( I see way too many people here complaining of this issue and making it clear they are shutting down and rebooting correctly for them all to be wrong -- at least a few a week. Meanwhile, I've had mine for ~6 months, work with it everyday, had power failures (one this morning, in fact) and never had a problem. There are rumors that rpi's from China are lower quality. I can't say whether that is true (or how to tell them apart), but Element 14 actually brag on their site now that they only sell the UK ones. But...
    – goldilocks
    Commented Sep 7, 2013 at 15:51
-2

I was stuck in read only mode as well. In my case I was able to force read only mode to work by running

mount -o remount, rw /

But then all sorts of other aspects didn't work. So to fix for good, I erased the SD card using disk utility on MacOS, as seen below:

enter image description here

Then I used Etcher to write the image (Raspbian in my case).

6
  • 2
    I do not understand. You formated the SD Card with a FAT file system and then mount the image? What image? Which partition do you format? The root partition needs an ext4 file system.
    – Ingo
    Commented Mar 26, 2018 at 10:42
  • I'm not very technically skilled with file systems, so a lot of this is going over my head. The image in my case was raspbian and I used Etcher to mount it
    – Alex
    Commented Mar 26, 2018 at 17:25
  • You don't need to format your SD-card before writing an image to it. When you write an image to an SD-card, it erases the existing partitions/formatting and rewrites it with that of the image file. (Also, Etcher writes images, mounting an image is something different.)
    – Max
    Commented Mar 28, 2018 at 16:00
  • Thanks for the clarification @Max. Despite what you say, this method solved my problem even after I had tried using just Etcher a couple times before (with no luck). Bottom line is that I had this issue, found a solution, and posted here to try and help out the next guy.
    – Alex
    Commented Mar 29, 2018 at 5:14
  • I'm glad it worked out, but it's important to know that the problem you encountered has nothing to do with formatting your card before writing an image to it. If you had this problem over and over again, you might have bad blocks on your SD-card that corrupt really quickly and then it's just a matter of time before it corrupts again. But hey, I'm still glad you got it to work ;)
    – Max
    Commented Mar 29, 2018 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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