Ubuntu Boot Hangs: Diagnosing and Fixing a Corrupted initrd

    This article explains why Ubuntu can hang during boot when the initrd/initramfs is corrupted or mismatched with the running kernel. It covers common causes, recovery by selecting an older kernel from GRUB, offline repair through a Live environment and chroot, and prevention practices.

    1. Symptoms and Background

    Many Linux users encounter this scenario after system updates or kernel-related operations: after reboot, the screen stops at a loading screen, with a blinking cursor or a frozen display. The system cannot enter the graphical interface or a terminal. Such “boot hangs” are often related to problems with the initial RAM disk (initrd/initramfs).

    To understand this issue, it helps to understand the Linux boot flow: BIOS/UEFI loads the bootloader (such as GRUB) → the bootloader loads the kernel image and initrd file → after the kernel starts, it uses drivers and tools in initrd to mount the real root filesystem → starts the init process → enters the system. The initrd file is a temporary “mini filesystem” used early in kernel boot. It contains storage drivers, filesystem modules, and other critical components needed to mount the real root partition. If initrd is corrupted, missing, or mismatched with the current kernel version, the kernel cannot complete the root filesystem mount, and the system naturally hangs in the early boot stage.

    2. Cause Analysis

    1. initrd and Kernel Version Mismatch

    The most common trigger is running a command like this:

    1. sudo update-initramfs -u

    This command updates the initial RAM disk. If the initrd file generated or overwritten during the update does not match the kernel version currently in use—for example, the kernel version specified during the update differs from the installed kernel, or the update was interrupted and the file was incompletely written—the kernel may load an initrd that cannot work on the next boot, causing a hang.

    2. Other Common Causes

    • Interrupted kernel upgrade: Power loss or a forced shutdown during the upgrade can leave the kernel image and initrd incompletely written.
    • GPU driver issues: After installing a third-party proprietary GPU driver, if the driver-compiled modules are not correctly included in initrd, boot may result in a black screen or hang.
    • Disk or filesystem errors: Errors on the root partition can cause the mount stage to fail.
    • Incorrect GRUB configuration: A boot entry points to a kernel or initrd file that has been deleted or does not exist.

    3. Repair Options

    Option 1: Select an Older Kernel from the GRUB Menu

    If multiple kernel versions are installed, this is the simplest recovery path:

    1. During boot, quickly and repeatedly press Shift (Esc on some machines) to bring up the GRUB kernel selection menu;
    2. Use the arrow keys to select an older kernel version that previously booted successfully;
    3. After entering the system, remove the problematic kernel and reinstall the correct version.

    If the menu contains only one kernel, proceed to Option 2.

    Option 2: Live Environment + chroot Repair

    The core idea is to use an external Linux environment (a Live USB or another machine with Linux) to mount the failed disk and reinstall the kernel there:

    1. Prepare a boot environment: Write the system to a USB drive to create a Live boot disk, or connect the failed disk to another Linux computer;
    2. Mount the failed root partition:
      1. sudo mount /dev/sdXn /mnt
      2. sudo mount --bind /dev /mnt/dev
      3. sudo mount --bind /proc /mnt/proc
      4. sudo mount --bind /sys /mnt/sys
    3. Switch the root directory:
      1. sudo chroot /mnt
    4. Reinstall the kernel and update initrd and GRUB:
      1. sudo apt install linux-image-x.x.x-generic
      2. sudo update-initramfs -u -k all
      3. sudo update-grub
    5. Finish up: Exit chroot, unmount the partitions, power off, reinstall the disk in the original machine, and verify boot.

    If the failure was caused by a GPU driver, uninstall the related driver in the chroot environment before updating initrd.

    4. Prevention Recommendations

    • Before running kernel-related commands, ensure the system retains at least one known working older kernel;
    • Ensure stable power during kernel upgrades and avoid forced shutdowns;
    • Back up important data regularly; for cloud deployments, use snapshots, images, or similar services to retain a rollback-capable system state;
    • After modifying drivers or kernel configurations, validate in a test environment before applying to production.

    5. Summary

    Ubuntu boot hangs are often caused by initrd mismatch or corruption. With two recovery paths—selecting an older kernel from GRUB and offline chroot repair—and an understanding of the boot flow, most such failures can be recovered without reinstalling the system. Good kernel management habits can effectively reduce the probability of recurrence.