Troubleshooting Techniques For Common Linux Boot Problems

Diagnosing Linux Boot Failures

When a Linux system fails to successfully boot, there are several common culprits that should be investigated first:

  • Failed hard drive or SSD – If the boot drive has failed mechanically or has severe file system corruption, the system will not be able to locate and load the kernel and initramfs image needed to boot.
  • Damaged bootloader – The Grand Unified Bootloader (GRUB) is prone to damage that can prevent loading the kernel. This can occur after changes to disk partitioning.
  • Incorrect kernel parameters – The kernel relies on accurate hardware parameters being passed by the bootloader configuration. Errors here can lead to a failed initramfs mount.
  • Corrupted initramfs image – The initial RAM file system image must successfully mount the real root file system. If this image is damaged, the boot process halts.
  • Inaccessible /boot partition – The bootloader and kernel reside on /boot, which must be mounted read-only early in the boot process. If the initramfs cannot access /boot, the boot process cannot complete.

Thoroughly checking each of these failure domains allows accurate diagnosis of the underlying issue preventing successful boot.

Recovering From a Damaged Bootloader

Identifying a Damaged Bootloader

A damaged GRUB bootloader may produce an error, but it may also simply fail to load properly and not display any error. On BIOS systems, this will often manifest as the system hanging indefinitely after POST completes. On UEFI systems, the firmware may report a boot failure.

To test for bootloader errors, boot from rescue media such as a Linux live CD and use utilities like grub-install and boot-repair to check the status of GRUB and related boot components. Failing commands or detected issues likely indicate a damaged bootloader needing repair.

Reinstalling GRUB Bootloader

If the GRUB configuration data or critical bootloader files have been corrupted, reinstalling GRUB will often resolve the failure:

# mount /dev/sda1 /mnt
# grub-install --target=i386-pc /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg

This will redeploy all bootloader files to the boot drive (here /dev/sda), then regenerate a working GRUB config referencing the detected Linux kernels.

Switching to a Different Bootloader

If GRUB reinstallation fails, an alternate bootloader like Syslinux may be substituted instead on BIOS/MBR systems:

# syslinux /dev/sda1 
# extlinux --install /boot/syslinux

This will replace GRUB with a functional but less feature-full Syslinux bootloader.

Fixing Kernel Parameter Issues

Identifying Incorrect Parameters

Kernel parameters instruct the Linux kernel about key hardware details needed during early boot. Error messages about invalid or unknown parameters typically indicate parameter issues.

On systems where the kernel still boots, warning messages about failures to activate certain subsystems due to malformed kernel parameters also indicate configuration problems.

Editing Kernel Parameters

Kernel parameters reside in the bootloader configuration file, which is /boot/grub/grub.cfg on GRUB systems. After editing, grub must be updated:

# vim /boot/grub/grub.cfg
(Edit parameters)
# update-grub

A common grub.cfg with kernel parameter edits:

menuentry "Ubuntu" {
  linux /vmlinuz ro root=/dev/sda2 debug init=/bin/bash
  initrd /initrd
} 

The updated parameters are passed to the kernel at next boot.

Rebuilding initramfs Image

For parameter changes to persist across kernel updates, the initramfs must also integrate the new details:

 
# mkinitramfs -o /boot/initrd.img

This ensures synchronization between initramfs and kernel.

Repairing a Corrupted initramfs

Symptoms of a Corrupted initramfs

A corrupted initramfs will typically fail to mount the intended root file system and halt boot with an error. Common error messages include:

VFS: Cannot open root device "(null)"
pivot_root: pivot_root (/sysroot, /sysroot/initrd) failed: 2
Kernel panic - not syncing: Attempted to kill init!

If the initramfs is severely damaged, boot will simply stop with no error displayed.

Regenerating initramfs

Most Linux distributions use utilities like mkinitcpio (Arch) or mkinitramfs (Debian/Ubuntu) to construct the initramfs:

# mkinitcpio -p linux

This will recreate initramfs from scratch using the current kernel version (linux).

Manually Rebuilding initramfs Image

The lsinitcpio tool allows manual initramfs generation:

# cd /boot ; mkdir initramfs
# cd initramfs
# lsinitcpio -c -g /boot/initramfs.img
# lsinitcpio -t -k /boot/vmlinuz0

This makes a standalone directory structure to bundle into the initramfs, initializes the image, and injects the kernel.

Regaining Access to /boot Partition

Booting from Live Media

When /boot is inaccessible, boot a Live Linux distribution from removable media to access the host file systems:

(On another system, write Live image to USB/DVD)

# Reboot target system 
# Boot from Live USB/DVD
# Mount local filesystems

Many Linux distributions have Live variants designed for rescue and recovery.

Mounting Partitions

Use the mount command to attach the host’s filesystem partitions:

  
# fdisk -l /dev/sda
# mount /dev/sda1 /mnt/boot

This mounts the /boot partition from the local drive to a recovery location.

Reconfiguring /boot Mount Point

To utilize the existing /bootpartition again, reconfigure fstab from the Live system:

# vim /mnt/etc/fstab
(Edit /boot mount options)  
/dev/sda1    /boot   ext2  defaults        0 0

Updated mount options should now be active after rebooting into the local system.

Leave a Reply

Your email address will not be published. Required fields are marked *