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!

Ghanima
  • 15,958
  • 17
  • 65
  • 125
Reid A
  • 73
  • 1
  • 1
  • 4

2 Answers2

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.

goldilocks
  • 60,325
  • 17
  • 117
  • 234
-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).

Max
  • 407
  • 1
  • 3
  • 9
Alex
  • 97
  • 2