When a Linux system suffers an unbootable kernel update, a broken GRUB bootloader configuration, or corrupted PAM authentication files, standard graphical recovery utilities and emergency recovery modes often fail to initialize. When your primary installation cannot boot on its own, utilizing the chroot (change root) command from an external live USB environment provides the ultimate rescue tool. By binding the live Linux kernel’s pseudo-filesystems into your installed system’s mount point, you can enter your installed operating system from the terminal, execute commands as the genuine root user, and repair critical system files directly.
Mastering the chroot recovery workflow enables system administrators and Linux users to rebuild the initial ramdisk (initramfs), reinstall UEFI bootloader binaries, and resolve package manager locks without reinstalling the operating system.
Step 1: Booting into a Live Rescue Environment
To begin system recovery, you need an external bootable Linux installation media:
- Create a bootable USB drive using standard distribution media such as an Ubuntu Desktop, Debian Netinst, or Fedora Workstation ISO.
- Connect the USB drive to the target computer, boot into the firmware boot selection menu (typically by pressing F12, F11, or Del during POST), and select the USB drive.
- Select Try Ubuntu or standard Live Desktop mode.
- Once the live environment loads, open a terminal window and switch to an elevated root shell:
sudo -i
Step 2: Identifying Partitions and Storage Layout
Before mounting drives, you must determine the precise device names for your root filesystem and UEFI system partition:
- List all block storage devices and existing filesystems:
lsblk -f
- Examine the output to locate your partitions:
- Root Partition: Typically formatted with
ext4,btrfs, orxfs(e.g./dev/nvme0n1p2or/dev/sda2). - EFI System Partition: A smaller partition (100 MB to 512 MB) formatted as
vfat/ FAT32 (e.g./dev/nvme0n1p1or/dev/sda1). - Separate Boot Partition (if applicable): Some enterprise installations maintain a dedicated
/bootpartition.
- Root Partition: Typically formatted with
Step 3: Mounting the Root and Pseudo-Filesystems
A standard chroot command changes only the root file path. However, tools like update-initramfs, grub-install, and apt require live hardware communication channels, process tables, and storage controller handles. You must bind the live host’s pseudo-filesystems into the mounted root directory:
- Mount the primary root filesystem under the temporary
/mntdirectory:
mount /dev/nvme0n1p2 /mnt
- If your system uses UEFI boot mode, mount the EFI partition to its corresponding directory inside
/mnt:
mount /dev/nvme0n1p1 /mnt/boot/efi
- Bind the dynamic kernel pseudo-filesystems (
/dev,/dev/pts,/proc,/sys, and/run):
for dir in /dev /dev/pts /proc /sys /run; do mount --bind $dir /mnt$dir; done
- Copy the live session’s domain name resolution configuration to guarantee internet connectivity inside the rescue environment:
cp /etc/resolv.conf /mnt/etc/resolv.conf
Step 4: Entering the Chroot Jail Environment
With storage and system devices securely linked, switch execution context into the target operating system:
- Execute the chroot binary targeting the mount directory:
chroot /mnt /bin/bash
- Notice that the terminal prompt transforms into the installed system’s root environment (e.g.
root@ubuntu:/#). Commands entered now execute directly against your installed operating system’s binaries, configuration files, and package database.
Step 5: Performing Common System Recovery Operations
Once inside the chroot environment, execute the required recovery tasks based on the specific boot failure:
- Rebuilding the Initial Ramdisk (Initramfs): If the system hangs during kernel handoff due to missing disk or storage drivers:
# Ubuntu / Debian
update-initramfs -u -k all
# RHEL / Fedora / Rocky Linux
dracut --regenerate-all --force
- Reinstalling and Updating the GRUB Bootloader: If the BIOS/UEFI boot entry vanished or the GRUB configuration file corrupted:
# For UEFI systems
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck
update-grub
- Resetting a Forgotten Root or User Password: If authentication is locked:
passwd username
- Resolving Broken Package Upgrades: If an interrupted system update locked the apt database:
dpkg --configure -a
apt update
apt --fix-broken install -y
Step 6: Exiting and Unmounting Cleanly
Never reboot your PC directly from an active chroot session, as abrupt power cycling can corrupt open filesystem journals:
- Exit the chroot jail back to the live USB shell:
exit
- Recursively unmount all bound pseudo-filesystems and storage partitions:
umount -R /mnt
- Reboot the system into your repaired installation:
reboot