Pages

Unixbhaskar's Blog

Thursday, February 20, 2014

How to fix "Read-only" root file system


This happened on Ubuntu 13.10.

Okay, I recently encounter it in one of my OS's installed in my laptop...there are many of them ..this is on Ubuntu...

After booting( I am accessing this partition after month or two!) it works fine for few minutes then all of a sudden it went back to Read-Only mode and that too root fs...irk...real irk...:(

So, I was doing an update to that OS after a while as I said..and it bug me twice..so started to hunt down that problem.I started to look around different aspect of fs and finally look at fstab..and it was little different then I thought.

The root fs was has the parameter of "on-error=errors=remount-ro" and which is missing the "defaults" option. Okay, what's the big deal with that "defaults" option..very big deal indeed.Please check out the mount man page to find out more about that option.

From the man pages of mount:

defaults
Use default options: rw, suid, dev, exec, auto, nouser, and async.


Now , I hope you understand why :)


But why the hell it was missing from the option in fstab file ...I was wondering..probably last update?or something else?Because I haven't had change anything in that file IIRC...or ...let me know if you believe and prof of something else doing that ..

Mind you, I have done two round of fsck after being hit by that to bring down that os and do it from other os partition.And the fsck fixed up few more thing..but still it was happening...so adding that options is simple and worked for me.

Hope this will help.

Cheers!
Bhaskar

3 comments:

  1. Hi,

    I have one doubt, actually if the error comes in hardisk or system files are corrupted, automatically it goes to read only mode when you rebooted. then why we will give errors=remount,ro?

    ReplyDelete
    Replies
    1. Really you don't understand?? Good to hear that...you might read this :

      Why does a file system go in read only mode?

      Problem: you have never intended to set your filesystems in read-only mode, but sometimes when your system is up, they remount of their own will. Why does this happen?

      Distributions often set an option in fstab that cause a filesystem to be remounted when an error occurs, which is typically caused by wrong on-disk format (maybe you have some bad blocks on your disk?). So check if the option errors=remount-ro is set on the filesystem:

      [root@lhost ~]# cat /proc/mounts
      (...)
      /dev/disk / ext3 rw,relatime,errors=remount-ro 0 0
      (...)

      You could remove the said option, but it would be a really bad idea. Instead, power up another system or a Live CD and try fsck-ing your filesystems. If the errors keep appearing shortly after cleaning the filesystem, it might be time to replace the hard drive. There are also ways to add certain blocks to a list of badblocks, which might help in some cases.

      And this :

      The errors=remount-ro option will mount the filesystem in read-only mode if in case problems occur during the mount process which prevents data loss.

      Delete
  2. It seems the disk have encounters some bad blocks...which is most probably causing this..I have seen it other places too.

    ReplyDelete