Diagnosing and Fixing GRUB Boot Failures in Linux
π
Nothing is more frustrating than rebooting your Linux server only to be greeted with a GRUB rescue prompt. Bootloader failures are among the most common startup issues, but they are also some of the most recoverableβif you know what to do.
If you see errors like:
π΄ error: no such partition
π΄ grub rescue>
prompt
π΄ kernel panic - not syncing: VFS: Unable to mount root fs
π Don't panic! In this guide, you will learn:
β
How GRUB works and why it fails
β
The difference between grub>
and grub rescue>
β
Step-by-step fixes for GRUB misconfigurations, missing partitions, and bootloader corruption
β
Enterprise-grade troubleshooting strategies for fast recovery
β
Best practices to prevent GRUB failures in production
π Next in the series: Recovering from Kernel Panics & Initramfs Issues
π 1. What is GRUB and Why Does It Fail?
GRUB (GRand Unified Bootloader) is the default bootloader for most Linux distributions. It loads the Linux kernel into memory and hands over control to the OS.
π‘ Common Reasons for GRUB Failures
Failure Type | Cause | Error Message |
---|---|---|
GRUB misconfiguration | grub.cfg is missing or incorrect |
error: no such partition |
Bootloader corruption | GRUB is missing from the MBR | grub rescue> |
Partition issues | The root partition was deleted or changed | error: unknown filesystem |
Kernel/initrd missing | Kernel or initramfs is missing from /boot |
kernel panic - not syncing |
π 2. Diagnosing GRUB Boot Failures
π‘ If your Linux machine fails to boot, check the type of GRUB prompt you see:
β
grub>
prompt β Partial GRUB working, just missing config
β
grub rescue>
prompt β GRUB cannot find critical boot files
β
Black screen, stuck at BIOS β Possible bootloader corruption
π Step 1: List Available Partitions
From the grub>
or grub rescue>
prompt, run:
ls
π Output Example:
(hd0) (hd0,msdos1) (hd0,msdos2) (hd0,msdos3)
π‘ This command lists all available disks and partitions. Identify where Linux is installed.
π Step 2: Locate the GRUB Configuration
Try to find the /boot/grub2/
directory:
ls (hd0,msdos2)/boot/grub2/
π Expected Output:
grub.cfg grubenv themes fonts
π‘ If you find grub.cfg
, GRUB exists but isnβt loading correctly.
π 3. Fixing GRUB Boot Failures
π οΈ Fix 1: Temporary Boot into Linux
If you reach the grub>
prompt but GRUB isn't loading properly, you can manually boot into Linux:
set root=(hd0,msdos2)
linux /vmlinuz root=/dev/sda2 ro
initrd /initramfs.img
boot
π Command Breakdown:
set root=(hd0,msdos2)
β Set the partition where Linux is installedlinux /vmlinuz root=/dev/sda2 ro
β Load the kernelinitrd /initramfs.img
β Load the initramfsboot
β Start the OS
β If this works, login and run the following to permanently fix GRUB:
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda
reboot
π οΈ Fix 2: Restore GRUB from a Live CD
If grub rescue>
appears, you may need to boot from a Linux Live USB and restore GRUB.
1οΈβ£ Boot from a Linux Live USB
2οΈβ£ Identify the root partition:
fdisk -l
3οΈβ£ Mount the partition and chroot into the system:
mount /dev/sda2 /mnt
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt
4οΈβ£ Reinstall GRUB:
grub2-install /dev/sda
grub2-mkconfig -o /boot/grub2/grub.cfg
exit
reboot
π Expected Outcome: GRUB is restored, and the system boots normally.
π οΈ Fix 3: Check for Missing Kernel or Initramfs
If you get kernel panic - not syncing
, check if the kernel and initramfs
exist:
ls /boot
π Expected Output:
vmlinuz-5.10.0 initramfs-5.10.0.img
π‘ If files are missing, regenerate initramfs and reinstall the kernel:
dracut -f
yum reinstall kernel
reboot
π 4. Enterprise Case Study: GRUB Failure in Production
π Scenario:
A data center running RHEL 8 experienced sudden downtime on a critical server cluster. After a scheduled update, systems rebooted into GRUB rescue mode.
π Investigation:
- Engineers connected via iLO (HP) & DRAC (Dell)
- Running
ls
in GRUB rescue showed missing partitions - Bootloader corruption detected after RAID firmware updates
π Solution:
πΉ Engineers booted from a Live Rescue USB
πΉ Chrooted into the system and reinstalled GRUB
πΉ Fixed boot order in BIOS settings
π Lesson Learned:
β οΈ Always test kernel and bootloader updates in staging environments first
β οΈ Keep offline recovery tools available for remote repair
π 5. Best Practices to Prevent GRUB Failures
π To minimize downtime, follow these enterprise best practices:
β
Test bootloader updates in staging before deployment
β
Keep multiple kernel versions installed in case a rollback is needed
β
Regularly back up GRUB configuration (grub.cfg
)
β
Use hardware-based remote management (IPMI/iLO/DRAC) for emergencies
β
Enable automatic boot monitoring via logs (journalctl -b -p err
)
π Summary
GRUB Failure Type | Common Cause | Solution |
---|---|---|
grub rescue> prompt |
GRUB bootloader missing | Reinstall GRUB from Live USB |
error: no such partition |
/boot partition missing |
Manually set root in GRUB |
Kernel panic - not syncing |
Missing initramfs or kernel | Rebuild initramfs (dracut -f ) |
π‘ Want to learn more? Check out the next article: "Recovering from Kernel Panics & Initramfs Issues" π
π¬ Join the Discussion!
π¬ Have you encountered GRUB boot failures in production?
π‘ What strategies do you use to quickly recover from boot issues?
π Share your experience in the comments!