How to Use chroot in Linux to Recover a Broken System from a Live USB

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:

  1. Create a bootable USB drive using standard distribution media such as an Ubuntu Desktop, Debian Netinst, or Fedora Workstation ISO.
  2. 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.
  3. Select Try Ubuntu or standard Live Desktop mode.
  4. 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:

  1. List all block storage devices and existing filesystems:
lsblk -f
  1. Examine the output to locate your partitions:
    • Root Partition: Typically formatted with ext4, btrfs, or xfs (e.g. /dev/nvme0n1p2 or /dev/sda2).
    • EFI System Partition: A smaller partition (100 MB to 512 MB) formatted as vfat / FAT32 (e.g. /dev/nvme0n1p1 or /dev/sda1).
    • Separate Boot Partition (if applicable): Some enterprise installations maintain a dedicated /boot partition.

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:

  1. Mount the primary root filesystem under the temporary /mnt directory:
mount /dev/nvme0n1p2 /mnt
  1. If your system uses UEFI boot mode, mount the EFI partition to its corresponding directory inside /mnt:
mount /dev/nvme0n1p1 /mnt/boot/efi
  1. 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
  1. 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:

  1. Execute the chroot binary targeting the mount directory:
chroot /mnt /bin/bash
  1. 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:

  1. 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
  1. 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
  1. Resetting a Forgotten Root or User Password: If authentication is locked:
passwd username
  1. 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:

  1. Exit the chroot jail back to the live USB shell:
exit
  1. Recursively unmount all bound pseudo-filesystems and storage partitions:
umount -R /mnt
  1. Reboot the system into your repaired installation:
reboot

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.