paulgorman.org/technical

Recovering from Linux Boot Problems

The system won’t boot. Now what?

Get a recovery/rescue/live image from which to boot. Most distros provide one.

The Debian installer has a rescue mode. At the installer “boot:” prompt, enter rescue/enable=true (on a RedHat-derived system: linux rescue). Move through the first few steps of the installer. At what would normally be the disk partitioning stage, we can select a partition to mount, including partitions on RAID or LVM volumes. Once selected, installer dumps us into a shell on that partition.

At that point, with our filesystem mounted, we must diagnose the problem. If we need to reinstall the boot loader on the master boot record, for example, run grub-install '(hd0)'.

It may be necessary to remount a read-only filesystem as read-write:

# mount -o remount,rw /

To mount all filesystems found in /etc/fstab:

# mount --all

If we don’t know the names of all physical partitions:

 # fdisk -l

If we don’t know the names of all LVM physical volumes, volume groups, or logical volumes, use pvdisplay, vgdisplay or lvdisplay.

If we’ve mounted the root partition in at a temporary mount point, and now want to change it it as root:

# chroot /mnt/tmproot

Fix broken grub (assuming we have the final/real /boot/ partition mounted):

# grub-install /dev/sdX
# grub-install --recheck /dev/sdX
# grub-install --recheck /dev/sdX

Repairing GRUB by mounting root

Mount the root partition:

# mount /dev/sdXN /mnt

Bind mount other necessary partitioins:

# for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done

Use parted or fdisk -l to find our EFI partition. It will have an “esp” flag and/or “EFI” type. Mount this partition.

# sudo mount /dev/sdXN /mnt/boot/efi

Change to our real root:

# chroot /mnt

Try to update grub:

# update-grub

If that doesn’t work, reinstall grub:

# grub-install /dev/sdX
# update-grub

What grub-install and update-grub actually do

grub-install should create the EFI boot entries. We can double-check this like:

%  efibootmgr -v

update-grub (re)generates a grub config file at /boot/grub/grub.cfg.