NOTE
If you experience a no such partition error, we have a separate guide for how to fix grub error: no such partition grub rescue
In this tutorial you will learn:
Grub rescue on a Linux system
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro using grub |
Software | GRUB |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions | # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command $ – requires given linux commands to be executed as a regular non-privileged user |
Let’s start with developing a basic understanding of grub. The grub files on your system can be found in /boot/grub. This directory contains the grub config file grub.cnf along with other files that are essential for grub to find and boot into your operating system(s).
Grub files on Linux
If one of these files gets deleted or otherwise edited to prevent grub from doing its job, you’ll find yourself at the grub rescue menu the next time you restart your computer. Other times, fiddling with partitions in a dual boot environment can cause similar issues. Either way, you end up needing to repair grub, which is what we’ll cover next.
When you get to a grub> prompt, you can use the following commands as an attempt to fix your boot loader and get booted back into your Linux distro.
grub> ls
(hd0) (hd0,msdos1)
grub> ls (hd0,msdos1)/
lost+found var/ dev/ run/ etc/ tmp/ sys/ proc/ usr/ bin boot/ home/ lib lib64 mnt/ opt/ root/ sbin srv/
grub> set root=(hd0,msdos1)
grub> linux /boot/vmlinuz root=/dev/sda1
grub> initrd /boot/initrd.img
grub> boot
# grub-mkconfig -o /boot/grub/grub.cfg
# grub-install /dev/sda
# reboot
If you are brought to the grub rescue> prompt when booting your computer, you’ll need to use live media to help repair your system. Once you are booted into the live environment, open up a terminal and type the following commands.
This should get your Linux install back up and running, even if grub had been completely broken or deleted from your system.
If grub doesn’t work properly, your computer doesn’t know how to load Linux. It can be really intimidating when the grub prompt loads up and none of the normal Linux commands seem to work. However, rescuing grub is pretty simple once you understand how it functions and what commands to use. The steps above should help you repair grub, whether it has just been misconfigured or requires a complete reinstallation.
# mount /dev/sda1 /mnt
# chroot /mnt
# grub-mkconfig -o /boot/grub/grub.cfg
# grub-install /dev/sda
# exit
# reboot