Knowledge Base:Recovering from a kernel boot failure

Synopsis
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.

Environment
Any Gentoo Linux installation.

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

The approaches are two-fold:


 * either try to get a root prompt from the (malfunctioning) system, or
 * boot from a LiveCD or other environment, mount the system and chroot to perform recovery steps.

Resolution
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 your partitions are reachable. The second one works in almost all circumstances as it is based on the installation of Gentoo again.

Getting a root prompt
To get a root prompt, reboot the system until you get to the Linux boot loader (such as GRUB). In the boot loader, edit the boot entry. For instance, with GRUB, this is done by pressing e (from edit). On the kernel line, add :

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

If the boot failure is because of a wrong  setting, you can correct this on the line as well. When you're finished editing, boot the entry (for GRUB, this means pressing b (from boot).

These changes (which are not persistent) will boot the system, but instead of calling the init binary, it immediately drops you into a root shell. From this shell, you can perform your recovery steps. Generally, you will also want to mount the root file system read-write as well as mount all other partitions:

Booting back from a LiveCD or other environment
Boot from the LiveCD (or a different environment) until you have shell access. Then, create the /mnt/gentoo mount point again and mount your root file system on it.

Next, bindmount /proc, /dev and /sys on top of it.

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

When 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.