How to Bypass Bad fstab Failure When Booting Linux

If /etc/fstab file is created with errors or the hardware configuration changes such as adding hard disks, Linux will boot into failure state. We can bypass the fstab failure by adding booting parameters to Linux. We can do this in two methods:

Method 1: Boot to single user mode

When booting into single user mode, Linux will not mount anything. Then we can remount the / to some directory in read/write mode and then edit the /etc/fstab.

  1. Boot Linux into single user mode

Press ESC in the grub menu and press ‘e’ to edit the grub entry. Add single to the kernel parameter like this:

kernel /vmlinuz-2.6.32.21-166.fc12.i686 ro root=/dev/mapper/VolGroup-LogVol00 vga=792 single

Then press ‘b’ to boot Linux.

  1. Remount / in read/write mode
    # mount -n -o remount,rw /
  2. Edit /etc/fstab

If the above method doesn’t work, the second method can be used:

Method 2: Add init=/bin/bash to kernel parameter

Add

rw init=/bin/bash

to kernel parameter. Linux will boot and we will get a bash prompt. The / is mounted in read/write mode. We can then edit /etc/fstab file and reboot.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

7 comments:

  1. Thanks mate, this really helped. I screwed up my fstab and was having trouble booting and then editing.
    Had to use ur method to mount in rw mode.

  2. instead of fstab, what about writing a cron script look for the target dirs and execute a mount script if they aren’t already mounted.

  3. I wrote a utility to vet the fstab. It checks for mis-spellings and quite a few other things such as duplicate entries, etc.
    It also generates a xref list.
    I am happy to make the utility available
    It can read the /etc/fstab or another from the same system (eg /tmp/fstab) wip copy.
    It also reformats the fstab quite nicely. Error diagnostics are provided.

  4. How to work around a systemctl daemon-reload failure where now, the system refuses to boot to mounting the partitions full RW. (They are mounted RO).

Leave a Reply

Your email address will not be published. Required fields are marked *