What the grub-rescue error means
The grub-rescue> (emergency recovery mode) prompt appears when the GRUB bootloader cannot find its modules, configuration file, or necessary kernel files. This is not an error code in the usual sense, but a special minimalist shell that launches during critical failures.
Symptoms:
- When turning on the computer, instead of the GRUB menu or system boot, the following line is displayed:
grub-rescue> - Commands like
lsandsetwork, but most standard GRUB commands (e.g.,menuentry) are unavailable. - The system does not boot past this screen.
grub-rescue mode is the bootloader's last line of defense. It allows you to manually specify the kernel location and initialize the boot, but it does not fix the GRUB configuration problem.
Causes
The error occurs because GRUB cannot read its files from the disk. Main causes:
- Corruption or loss of GRUB files in the
/bootpartition (e.g.,grub.cfg, modules in/boot/grub). - Change in disk order in BIOS/UEFI or physical reconnection (e.g., reconnected a SATA cable, and
hd0becamehd1). - Incorrect GRUB installation (e.g., to a partition instead of MBR/ESP, or to a different disk).
- Corruption of the partition table or
/bootfilesystem. - Deletion or compression of the
/bootpartition without updating GRUB. - Interrupted kernel/GRUB update (update was interrupted,
/bootran out of space). - Error in GRUB configuration (
grub.cfg), causing the bootloader to fail to find the kernel.
Method 1: Temporary system boot via rescue shell
This method does not fix GRUB, but allows you to boot into the system to restore the bootloader from within.
- At
grub-rescue>, list disks and partitions:ls
Output may be:(hd0) (hd0,msdos1) (hd0,msdos2) (hd1) (hd1,msdos1)... - Check each partition for kernel files:
ls (hd0,msdos1)/
Look for directoriesboot,grub,grub2or filesvmlinuz-*,initrd.img-*. - When you find the system partition (e.g.,
(hd0,msdos1)), set it as root:set root=(hd0,msdos1) - Find the exact kernel filename (version may differ):
ls /boot/vmlinuz-*
Suppose the file is:/boot/vmlinuz-5.15.0-78-generic - Load the kernel and initrd:
linux /boot/vmlinuz-5.15.0-78-generic root=/dev/sda1 ro quiet initrd /boot/initrd.img-5.15.0-78-generic
Theroot=parameter points to the root partition (usually/dev/sda1or/dev/nvme0n1p1). Verify it vials (hd0,msdos1)/etc/fstabor by partition size. - Boot the system:
boot - After a successful boot, immediately reinstall GRUB (see Method 2).
⚠️ Important: If
grub-rescue>does not see thelscommand or disks are missing entirely, the problem may be with the disk driver (e.g., for RAID or NVMe). In this case, you need a LiveCD.
Method 2: Full GRUB reinstallation from a Live medium
Recommended method. Requires a bootable Linux USB (Ubuntu, Fedora, any live distro).
- Boot from the Live USB and open a terminal.
- Identify how your system disk is named in the Live environment:
sudo fdisk -l
Find the Linux partition (usually/dev/sda1,/dev/nvme0n1p1, etc.). If you have UEFI, also find the ESP partition (FAT32, ~100-500 MB, typeEFI System). - Mount the root partition:
sudo mount /dev/sda1 /mnt
If you have a separate/boot, mount it to/mnt/boot:sudo mount /dev/sda2 /mnt/boot - For UEFI, mount the ESP partition:
sudo mount /dev/sdaX /mnt/boot/efi # X — ESP partition number - Mount system virtual filesystems:
sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys - Enter the chroot environment:
sudo chroot /mnt - Reinstall GRUB:
- For BIOS/MBR (disk
/dev/sda):grub-install /dev/sda - For UEFI (ESP already mounted at
/boot/efi):grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
- For BIOS/MBR (disk
- Update the configuration:
update-grub
It should detect kernels and create a menu. - Exit chroot and reboot:
exit sudo reboot
Remove the Live USB during boot.
Method 3: Restore GRUB configuration without LiveCD (if system booted via Method 1)
If you managed to boot temporarily, restore the GRUB configuration from within the system.
- Verify GRUB files are in place:
ls /boot/grub
Should containgrub.cfg,i386-pc/(for BIOS) orx86_64-efi/(for UEFI). - Regenerate the configuration file:
sudo update-grub
Or, ifupdate-grubis unavailable:sudo grub-mkconfig -o /boot/grub/grub.cfg - If the config was restored but GRUB still doesn't boot, reinstall it to the boot partition:
# For BIOS: sudo grub-install /dev/sda # For UEFI (if ESP is mounted at /boot/efi): sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi - Reboot:
sudo reboot
Method 4: Manual GRUB file recovery (emergency option)
If GRUB files were deleted or corrupted, but you have a backup or they exist elsewhere.
- From LiveCD (as in Method 2), enter chroot.
- Check if the GRUB package is installed in your system:
dpkg -l grub-pc # For Debian/Ubuntu rpm -qa | grep grub2 # For RHEL/CentOS/Fedora - If the package exists, reinstall it:
# Debian/Ubuntu: sudo apt-get install --reinstall grub-pc grub-common # RHEL/CentOS (with EPEL): sudo dnf reinstall grub2 - Then run
grub-installandupdate-grub(steps from Methods 2 and 3). - If the package is missing, install it via the package manager from within chroot.
- If there is no network in the Live environment, copy GRUB files from another working computer (compatible architecture and version) to
/mnt/boot/gruband to the boot partition (for UEFI — to the ESP).
Prevention
To avoid recurrence:
- Do not delete or compress the
/bootpartition after system installation. If resizing is needed, use GParted from a bootable disk, then reinstall GRUB. - When updating the kernel, ensure there is enough space on the
/bootpartition (at least 200 MB). Remove old kernels viaapt autoremoveordnf autoremove. - Avoid changing disk order in BIOS/UEFI. If you change cables, update the GRUB configuration.
- Regularly back up critical partitions (especially
/bootand ESP) or create system snapshots (Btrfs, ZFS). - When installing GRUB, always specify the physical disk (e.g.,
/dev/sda), not a partition (e.g.,/dev/sda1), if using BIOS. For UEFI — the ESP should be a separate FAT32 partition. - After any partition operations (creation, deletion, resizing), reinstall GRUB from a LiveCD.
Additional questions
What to do if ls is missing in grub-rescue?
This indicates serious issues with disk drivers. Try booting with LiveUSB and check if the disk is visible in fdisk -l. If not — the problem may be hardware-related (cable, controller) or with a RAID/NVMe driver that fails to load in rescue mode.
Can GRUB be restored automatically?
No, there is no auto-repair in grub-rescue. All steps require manual input. However, after a successful boot, you can configure automatic configuration regeneration via grub-mkconfig on each kernel update.
Why does grub-rescue reappear after GRUB recovery?
Most often this means GRUB was installed to the wrong partition or disk. Check:
- For BIOS:
sudo fdisk -l— is there a partition table? Where is the MBR located? - For UEFI: is the ESP mounted? Is GRUB installed to the correct EFI entry (
efibootmgr)? - Is the
rootingrub.cfgset correctly?