There are few scenarios more terrifying for a Linux user than turning on their computer and being greeted not by the familiar Ubuntu loading screen, but by a stark, black terminal displaying a “GRUB rescue” error or a “No bootable device found” warning. When the GRUB bootloader becomes corrupted—often due to a failed system update, a dual-boot configuration gone wrong, or a suddenly resized partition—your operating system is entirely inaccessible. However, unlike Windows, Linux provides a remarkably powerful backdoor to fix a broken system without losing a single file. By learning how to use a Live USB and chroot to repair the Ubuntu bootloader, you can mount your broken file system from the outside and force a fresh, healthy installation of GRUB directly onto your hard drive.
In this advanced system rescue guide, we will walk you through the precise terminal commands required to execute this high-level repair. We will explain the theory behind the `chroot` (change root) command, how to properly mount your critical system directories, and how to surgically rebuild your bootloader so your machine starts flawlessly once again.
Understanding the ‘chroot’ Environment
To fix the bootloader, you need to issue commands to your installed Ubuntu system. But because the system will not boot, you cannot open a terminal inside it. This is the ultimate catch-22.
The chroot command is the solution. It allows you to boot your computer using a temporary operating system (a Live USB) and then “trick” that temporary system’s terminal into acting as if it were the terminal of your broken, installed system. Once the environment is shifted, any command you type (like grub-install) affects the broken hard drive, not the USB stick.
Prerequisites for the Rescue Operation
Before you can begin the repair, you must have the necessary rescue tools prepared.
- A Live USB: You need a USB flash drive (at least 4GB) containing a bootable version of Ubuntu. Ideally, this should be the exact same version of Ubuntu that is currently broken on your hard drive (e.g., Ubuntu 24.04 LTS).
- Internet Access: While not strictly mandatory for a basic GRUB reinstall, having an active internet connection during the Live session is highly recommended in case you need to download missing packages (like
grub-efi-amd64).
Step 1: Boot into the Live Environment
- Insert the Live USB into your broken computer and turn the machine on.
- Immediately press your manufacturer’s boot menu key (often F12, F10, or F8) and select the USB drive.
- When the Ubuntu installation menu appears, do not click Install Ubuntu. You will erase your data. Instead, click Try Ubuntu to launch the live graphical desktop.
Step 2: Identify Your Hard Drive Partitions
Once you are on the Live desktop, open a terminal (Ctrl + Alt + T). You must identify exactly where your broken Ubuntu system is installed.
- Type the following command and press Enter:
sudo fdisk -l - Look at the output. You are searching for your main Linux partition (usually formatted as
ext4) and, if you have a modern UEFI system, your EFI boot partition (usually formatted asvfatorFAT32, around 500MB in size). - Take note of the identifiers. For this tutorial, we will assume your main Linux partition is
/dev/sda2and your EFI partition is/dev/sda1. (Your numbers may be nvme0n1p2 or sdb2, so substitute accordingly).
Step 3: Mount the Broken File System
We must now attach your broken hard drive to the Live USB’s directory tree.
- Mount your main Linux partition to the
/mntdirectory:sudo mount /dev/sda2 /mnt - If you have a UEFI system (which almost all PCs built after 2012 do), you must also mount the EFI partition:
sudo mount /dev/sda1 /mnt/boot/efi
Step 4: Bind the Virtual File Systems
For the chroot environment to function correctly, the broken system needs access to the temporary hardware interfaces running on the Live USB. You must bind these specific directories.
Run the following command string exactly as written:
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
Step 5: Enter the chroot Environment
Your directories are prepared. It is time to shift the terminal.
Type the following command and press Enter:
sudo chroot /mnt
Notice that your terminal prompt has changed. You are now operating as the root administrator from inside your broken operating system.
Step 6: Reinstall and Update GRUB
Now for the actual repair. You simply need to instruct the system to reinstall the bootloader to the primary drive.
- Install GRUB to the main drive. Note: you target the entire drive (e.g.,
sda), not the specific partition (sda2).grub-install /dev/sda - If the installation reports no errors, you must now update the configuration file so GRUB detects all your operating systems:
update-grub
Step 7: Safely Exit and Reboot
Do not simply pull the USB stick out. You must exit the environment gracefully to ensure data integrity.
- Exit the chroot environment by typing:
exit - Unmount all the virtual file systems and your hard drive:
sudo umount -a - Reboot the computer normally:
reboot
When the computer restarts, remove the Live USB. You should be greeted by the familiar, repaired GRUB boot menu. A broken bootloader can seem like a catastrophic failure, but the open-source nature of Linux ensures you are never truly locked out. By mastering how to use a Live USB and chroot to repair the Ubuntu bootloader, you transform a potential system wipe into a straightforward, logical terminal exercise.