Are you experiencing a Linux boot failure? Don’t worry! GRUB Rescue can help get your system back up and running. This guide will show you how to fix your Linux boot issues using GRUB Rescue. Whether it’s missing files, incorrect boot parameters, or multi-boot problems, our clear instructions will help you troubleshoot and repair your system. Let’s dive in and get your Linux back on track!
Safer for Newer Linux Users: This blog focuses on standard Linux commands and tools that minimize the risk of system damage, as everything is conducted in a controlled environment (rescue mode). While there are many other blogs in Internet that offer simpler solutions, they often come with higher risks.
Symptoms of GRUB Corruption
- The system fails to boot and is stuck at the GRUB prompt.
- You may see the system enter “GRUB rescue mode,” indicating a corrupted GRUB configuration.
Steps to fix Linux Boot Failure using GRUB Rescue
- Boot from a Live CD/ISO:
Insert a bootable Linux installation media (live CD or USB) into the machine.
Set the default boot device to a CD/DVD drive or USB in the system BIOS/firmware settings.
Reboot the system to boot from the installation media.
- Enter Rescue Mode:
From the boot menu of the installation media, choose the option for “Troubleshooting” and then “Rescue a CentOS Linux system” (or the equivalent for your distribution).
Wait for the necessary components to load into rescue mode.
- In the next screen enter the number 1 and Press Enter key 2 times.
- Identify Boot Partition:
List the available partitions usinglsblk
to identify where the boot partition is located:
lsblk
- Mount the Filesystem:
When prompted, choose to mount the filesystem in read-write mode. The filesystem is usually mounted under/mnt/sysimage
. Change the root to this mounted filesystem using thechroot
command:
chroot /mnt/sysimage
- Reinstall GRUB:
Install GRUB on the boot device using the following command. [Replace/dev/sdX
with the appropriate device name for your system’s boot device (e.g.,/dev/sda
).]
grub2-install /dev/sdX
- Reconfigure GRUB:
If the GRUB configuration file (grub.cfg
) is missing or corrupted, regenerate it using:
grub2-mkconfig -o /boot/grub2/grub.cfg
Ensure there are no spelling mistakes in the command, and verify that it completes successfully.
- Verify the GRUB Configuration: Check that the
grub.cfg
file has been recreated:
cat /boot/grub2/grub.cfg
- Exit and Reboot:
Exit the chroot environment with the commandexit
andreboot the system
with thereboot
command.
exit
reboot
Ensure that the system boots into the OS normally without returning to the GRUB prompt.
If the system boots again to Live CD/Bootable device again, change the boot order in BIOS settings to HardDisk as first priority!
Special Considerations for UEFI Systems
For systems using UEFI rather than legacy BIOS:
- The GRUB configuration files are located in the
/boot/efi/EFI
directory. - Ensure you are in the correct directory before running configuration commands.
- The commands for reinstalling and configuring GRUB may vary slightly depending on the distribution and UEFI setup.
Recovering a corrupt GRUB is a straightforward process involving booting into a rescue environment, mounting the filesystem, and reinstalling or reconfiguring GRUB. By following these steps, you can restore your system to a bootable state and regain access to your Linux environment.