41

It seems that I have added incorrect record to /etc/fstab:

//servername/share    /mnt/share    cifs     defaults,username=myuser     0 0

When I did mount -a, it asked user password to mount network share. It seems that it cannot proceed without password on boot, so it is just hung.

How can I fix fstab to prevent boot failure?

4 Answers 4

65

It seems that I’ve found a solution:

  • At the GRUB prompt, hit A to append options.
  • Add init=/bin/bash to the end of the kernel command line and press Enter.

The system will boot to a prompt like bash-3.2# enter the following commands at the prompt

mount -o remount,rw /

Then edit the fstab:

vim /etc/fstab

Edit the fstab file commenting the errors by adding a # at the begining of each problematic line, save the file and reboot by pressing Ctrl+Alt+Del.

6
  • 8
    I had to use mount -o remount,rw / --target / to succesfully remount in rw mode. Elsecase mount was picking the bad values from /etc/fstab, see the man mount for details.
    – laconbass
    Oct 18, 2016 at 12:14
  • 2
    @laconbass you are damn right, --target / is the key!
    – sempasha
    Jul 28, 2017 at 16:46
  • This is still true today - over six years later. Anyway on CentOS7 the key for changing an entry on boot is now tab, and once on bash you have to mount your filesystem (which is still unmounted at this stage) with a simple mount /dev/sda(X) /mnt (obviously changing the root partition with the right one)
    – nnsense
    Oct 28, 2018 at 9:59
  • Saved my life.. Jun 23, 2019 at 22:20
  • 1
    On RHEL 8 variants. Hit e on the kernel selection screen and you will get the grub prompt. The line to append init=/bin/bash is the one starting with linux. The rest is as per OP
    – Detritus
    Jun 10 at 11:47
3

How about removing the entry, creating a snapshot and then trying to change your /etc/fstab so you have a working snapshot you can roll back to?

According to the manpage mount.cifs you can also specify a password via password=arg. Also, according to that manpage there is no argument username=arg but instead user=arg. But it might be different on your system, better check your manpage for the correct argument names.

3
  • man for the win.
    – Tim
    Jul 26, 2012 at 13:22
  • I was about to create snapshot, but while I was experimenting with fstab, vm instance went off for some reason. Apparently, I wouldn't ask the question if I could fix it myself.
    – altern
    Jul 26, 2012 at 13:31
  • 2
    Your problem description is a little bit unclear. Can't you boot in single user / recovery mode? It should only try to mount the root fs and leave the fstab alone.
    – scai
    Jul 26, 2012 at 13:54
1

The other easy way is booting to live-cd mode and mount the right partition. Then you can fix anything you want!

1

I found a solution to systems error kernel not loading Use live cd to gain access to your existing installation. Once in reinstall Linux kernel :

pacman -S Linux

Then delete the fstab file from etc/fstab :

rm /etc/fstab

Now reinstall systemd:

pacman -S systemd

When reinstalling systemd it will automatically generate a new fstab file

Now reinstall the bootloader in this case I use grub:

pacman -S grub os-prober

(os probe is useful if you have more than 1 os installed on your hdd/ssd) Then

grub-install --target=i386-pc /dev/sda

Once finished make the configuration files:

grub-mkconfig -o /boot/grub/grub.cfg

Then unmount the partitions in use and reboot

umount /dev/sdX 
reboot

This should fix the problem, it worked for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .