Knowledge Base:Recovering from a kernel boot failure

From Gentoo Wiki
Jump to: navigation, search


Booting a Gentoo Linux system fails to boot up properly. No recovery mode is presented (such as a single-user login) but the boot loader does work properly.


Any Gentoo Linux installation.


Boot failures can have several reasons. This article will focus on generic approaches to recover from such failures.

The approaches are two-fold:

  1. Try to get a root prompt from the (malfunctioning) system, or
  2. Boot from a LiveCD or other environment, mount the system and chroot to perform recovery steps.


There are several possible resolutions to fix a boot failure. The first one, which covers how to get a root prompt, is especially useful if partitions are reachable. The second one works in almost all circumstances as it is based on the installation of Gentoo.

Getting a root prompt

To get a root prompt, reboot the system until the Linux boot loader (such as GRUB) appears. In the boot loader, edit the boot entry. For instance, with GRUB, this is done by pressing the E key (for edit). On the kernel line, add init=/bin/sh:

kernel /kernel root=/dev/sda3 init=/bin/sh

If the boot failure is because of a wrong root= setting, then correct it using the kernel line as well. When finished editing, boot the entry (for GRUB, this means pressing the B key (for boot).

These changes (which are not persistent) will boot the system, but instead of calling the init binary, it immediately drops the init process into a root shell. From this shell recovery steps can be performed. If persistent changes need to be made the root file system, as well as all other partitions that needs changes, should be mounted as read-write:

root #mount -o remount,rw /
root #mount -a

Booting back from a LiveCD or other environment

Boot from the LiveCD (or a different environment) until the environment grants shell access. Create the /mnt/gentoo mount point (if one does not exist) and mount the root file system on it:

root #mkdir /mnt/gentoo
root #mount /dev/sda3 /mnt/gentoo

Next, bindmount /proc, /dev and /sys on top the /mnt/gentoo mountpoint:

root #mount --rbind /proc /mnt/gentoo/proc
root #mount --rbind /dev /mnt/gentoo/dev
root #mount --rbind /sys /mnt/gentoo/sys

Finally, chroot into the environment, mount the remaining partitions, and start recovering the system:

root #chroot /mnt/gentoo /bin/sh
root #source /etc/profile
root #mount -a

Once finished with the recovery steps, umount all partitions, exit the chroot, umount the remaining partitions, and reboot back into the system to see if the recovery has succeeded:

root #umount -a
root #exit
root #umount -l /mnt/gentoo/{dev,proc,sys,}
root #sync
root #reboot