Skip to content
linux system-management

chroot

chroot recovery linux boot-repair live-usb
Plain English

chroot lets you step inside another Linux installation and work as if you had booted it. The usual reason is repair: your installed system will not start, so you boot from a USB stick, point chroot at the broken system’s disk, and run its own tools to fix it. Commands you run affect the installed system, not the USB stick.

Technical Definition

chroot (change root) calls the chroot() system call so a process and its children see a given directory as /.

What it changes: path lookups. Programs inside resolve /etc, /usr, and /boot against the new root, so apt, update-grub, and grub-install act on the installed system.

What it does not change: the running kernel, hardware, and processes outside it. You need the host’s virtual filesystems mounted in so tools can see devices: bind-mount /dev, /proc, /sys, and on UEFI /sys/firmware/efi/efivars.

Not a security boundary. A root process can break out of a chroot. For isolation use containers, which build on namespaces and cgroups.

Typical rescue sequence from a live USB:

  1. Identify partitions with lsblk -f
  2. Mount root at /mnt, then the ESP at /mnt/boot/efi
  3. Bind-mount /dev, /proc, /sys
  4. sudo chroot /mnt
  5. Repair, then exit, unmount in reverse order, and reboot

Ubuntu also ships arch-chroot-style helpers in some tools, but the manual steps work everywhere.

Source: chroot(2) Linux manual page

Repairing GRUB from a live USB with chroot

$ lsblk -f
$ sudo mount /dev/sda2 /mnt
$ sudo mount /dev/sda1 /mnt/boot/efi
$ for d in dev proc sys; do sudo mount --bind /$d /mnt/$d; done
$ sudo mount --bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars
$ sudo chroot /mnt

# Now inside the installed system
root@ubuntu:/# grub-install --target=x86_64-efi --efi-directory=/boot/efi
root@ubuntu:/# update-grub
root@ubuntu:/# exit

$ sudo umount -R /mnt
In the Wild

chroot is the standard way to fix a Linux system that cannot boot itself: reinstalling GRUB, rebuilding an initramfs, removing a broken package, or fixing fstab with the system’s own editor and tools. The mistakes are mounting the wrong partition, forgetting the bind mounts (so grub-install complains it cannot find EFI variables), and forgetting the ESP. Practice it in a VM snapshot before you need it on real hardware.