PDA

View Full Version : Can't edit fstab as it's a read only file



worldttle
11th January 2007, 05:18 PM
I had to remove one of my harddisks because it crashed. Now when I boot I get kicked to bash when the system cannot find the removed harddisk and won't proceed any further.

I have tried repeatedly to edit fstab using the vi editor to remove the line that references the harddisk which has been removed. However I always get the message that fstab is a read only file.

However chmod shows I have read/write permission for fstab. What am I missing here?

Thanks.

leigh123linux
11th January 2007, 05:20 PM
I had to remove one of my harddisks because it crashed. Now when I boot I get kicked to bash when the system cannot find the removed harddisk and won't proceed any further.

I have tried repeatedly to edit fstab using the vi editor to remove the line that references the harddisk which has been removed. However I always get the message that fstab is a read only file.

However chmod shows I have read/write permission for fstab. What am I missing here?

Thanks.

You need root permission to edit this file


su -
gedit /etc/fstab


or for kde


su -
kwrite /etc/fstab

try nano for editing

worldttle
11th January 2007, 06:25 PM
Thank you for your suggestion, but after using su - , nano nor vi still not allow me to edit fstab.

Nano gives the message: [ Error writing fstab: Read-only file system ].

John

srs
11th January 2007, 06:34 PM
Try to edit fstab after booting to failsafe mode.

Seve
11th January 2007, 06:35 PM
Hello:
After typing
su -
did you enter your root password and then enter and then
type
gedit /etc/fstab

Seve

pete_1967
11th January 2007, 06:40 PM
And if, when you try to save the file (:w) in Vim it tells you file is read-only, add exclamation mark at the end of write command -> ':w!'

nick.stumpos
11th January 2007, 06:43 PM
is it immutable try as root chattr -i

worldttle
11th January 2007, 06:44 PM
When the boot process aborts upon failing to find the removed harddisk, it asks for a password before dropping into bash. At this point I enter my root password before (I assume) entering bash.

When I type su -, it does not ask for a password. I just get the prompt line again. I would guess su see that I'm already logged in as root?

How do I boot into failsafe mode?

Thanks.

worldttle
11th January 2007, 06:46 PM
Nope, :w! doesn't do it.

Thanks.

pete_1967
11th January 2007, 06:51 PM
You are doing something seriously wrong now.

do `ls -l /etc/fstab`in console and post the result here. Also do `whoami` in console and post the result here (when you are logged in as root).

srs
11th January 2007, 06:59 PM
I should rather called failsafe for runlevel 1 (single-user mode)... Anyway, boot into single-user mode and try the following taken from http://www.unixguide.net/linux/faq/04.15.shtml:

Root File System Is Read-Only
Remount it. If /etc/fstab is correct, you can simply type:

mount -n -o remount /

If /etc/fstab is wrong, you must give the device name and possibly the
type, too: e.g.

mount -n -o remount -t ext2 /dev/hda2 /

To understand how you got into this state, see, ("EXT2-fs: warning:
mounting unchecked file system.")

worldttle
11th January 2007, 07:01 PM
ls -l /etc/ftab returns -rw-r--r-- 1 root root 729 Oct19 2237 /etc/fstab

whoami returns root

By the way, when the boot process stops, it asks for the root password to continue or Ctr-D to reboot. I enter the root password at this point and get the '(Repair filesystem) 1 #' prompt.

Thanks.

worldttle
11th January 2007, 07:13 PM
Bingo! srs is correct.

mount -n -o remount / allowed fstab to be edited.

Thanks to everyone.

fnmblot
17th January 2007, 04:55 AM
Thanks a million for this post! I was almost ready to reinstall FC6.
fnmblot

Jongi
17th January 2007, 12:08 PM
Great stuff srs. I once *****ed about why in that state you couldn't get write access instead you had to boot from the rescue disk. This will prove very valuable I am sure.

AndyS
18th May 2009, 10:33 PM
Thanks SRS. That saved me a ton of time

wildcard442
26th June 2009, 04:24 AM
Thank you! this answered my question!

fcbinfo
17th September 2009, 02:54 PM
I should rather called failsafe for runlevel 1 (single-user mode)... Anyway, boot into single-user mode and try the following taken from http://www.unixguide.net/linux/faq/04.15.shtml:

Root File System Is Read-Only
Remount it. If /etc/fstab is correct, you can simply type:

mount -n -o remount /

If /etc/fstab is wrong, you must give the device name and possibly the
type, too: e.g.

mount -n -o remount -t ext2 /dev/hda2 /

To understand how you got into this state, see, ("EXT2-fs: warning:
mounting unchecked file system.")


3 years after....

This post save my life !

I register on the forum only for say "THANK YOU SRS" !

teo959
18th November 2009, 11:12 PM
thank you SRS, you are a great man!

ragsshishya
18th February 2012, 08:07 AM
SRS,

Mr. Supreme guru ... you had literally bailed me out of a 4 Hour overnight struggle , if not for noble souls like you ..not even a single strand of hair would be left on my skull ..thanks a lot ..

I was trying to mount an external usb hard drive in order for Mediatomb to read my audio and video file ....Mediatomb seems to be more stubborn than my wife it was just not giving in ...

That is when my ordeal started...I had edited the fstab file so that the external hdd mounts and Mediatomb could some how read ...all in vain ...

Instead of the nirvana of blissfully listening to media content from external hdd ....i some how landed up ruffling my ubuntu os ...(I can't blame the poor ubuntu ..after innumerable reboots to get the xternal hdd going ...even the os has its limits ) ....it just was not booting into the gui ....after 2 hours of this ordeal my head was like a scrambled egg ...i edited my fstab file to the point of no return ...

As destiny would have it ....some one else had confronted the same issue earlier in time ....the reason for my landing in this forum ...I did the following :

mount -n -o remount / (when it gives the manual recovery option ..logged in as root )

edited etc/fstab on terminal using the following command

sudo nano -bw /etc/fstab

was able to delete the line ...and save the file using Ctrl o in the editor (No dreaded read only file alert )

and was able to boot into linux .....

thanks srs and worldttle



ragsshishya

fernandodrm
9th January 2013, 05:32 PM
Almost 5 years later, srs saved my life, literaly. Thank you!!!!

FrankFibonacci
14th February 2013, 06:52 AM
Specifically registered to say thanks to SRS!

5 year old post saved my life too!

In my case, the system was trying to mount a partition that no longer existed but there was an entry in /etc/fstab. Upon rebooting it took me to "maintenance mode" where everything is read only even though you are root. Using w! doesn't even work.

Im using RHEL6 and SRS solution worked well.

rs120p
18th July 2013, 10:25 PM
RHEL5.4
Was messing around with /dev/loop0 in /etc/fstab (Don't do it!) :)
it worked until reboot

mount -n -o remount / allowed fstab to be edited in "Single" mode


Even though its a crash test system I forgot to clone my VM Guest first and this saved a LOT of time
Plus its a smarter fix

I registered just to THANK SRS!
THANKS!!!!!

jpollard
18th July 2013, 10:31 PM
You just might have to remount root as read/write first...



mount / -orw

sidebrnz
19th July 2013, 12:36 AM
What astonishes me here isn't the fact that a five-year-old thread is still useful, it's the fact that it took them so long to read the error message and understand that it was saying that the file system was read only, not the file.

ShaMonkey
12th June 2014, 09:43 AM
Thank you kindly srs. It's June of 2014 and you just saved my bacon. What are we looking at now close to 7 and half years and counting. not too bad

I was disabling access time logging to save a little wear and tear on my new ssd but when i edited the /etc/fstab i typed a period where a coma should have gone and as soon as i rebooted everything went south.
I once i managed to figure out what had happened and get back in there the fstab couldn't be edited because it was read only. Remounting the root is exactly what was needed. Thanks man, much appreciated for the solution.