21

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?

32

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 /
  • vim /etc/fstab

edit the fstab file commenting the errors by adding a # at the begining of each problematic line, save the file

  • reboot by pressing CTRL+ALT+DEL
  • 3
    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 '16 at 12:14
  • @laconbass you are damn right, --target / is the key! – sempasha Jul 28 '17 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 '18 at 9:59
2

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.

  • man for the win. – Tim Jul 26 '12 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 '12 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 '12 at 13:54
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.

0

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

0

May be I am too late. But this is FYI. In this situation you can use nano to load fstab and you can restart after editing the fstab.

sudo nano /etc/fstab

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.