The default bootloader for systems based on the Linux kernel is the GRUB (How to Use Grub Rescue to Fix Linux Boot Failure?), a tool for booting and loading operating system kernels. Regular users hardly ever see GRUB in use, despite the fact that it starts up immediately when a computer is turned on. It runs automatically and doesn’t need any input from the user.
On the other hand, if you try to boot another operating system at the same time as Linux on the same machine, the bootloader of the other system can overwrite GRUB, making it impossible for Linux to start
This article will demonstrate How to Use Grub Rescue to Fix Linux Boot Failure? and the Boot Repair programmer to resolve a Linux boot problem.
- An account with sudo privileges.
- Access to the command line.
GRUB Boot Problems
The most frequent cause of GRUB failing to boot into the operating system is that the bootloader of another OS has overwritten the GRUB boot configuration. When trying to dual boot with an existing Linux installation, the issue arises. The unintentional deletion of GRUB configuration files is another factor.
The GRUB Rescue prompt comes if GRUB is unable to boot the machine.
The “no such partition” error is displayed by GRUB in the aforementioned case before the grub rescue question appears. “Unknown filesystem,” followed by the same query, is a typical GRUB error.
Sometimes, the screen might just display the grub prompt.
Rescue Commands for GRUB
How to Use Grub Rescue to Fix Linux Boot Failure? The list of frequently used GRUB Rescue commands is shown below. Use the commands listed in the preceding section’s prompts.
Command | Description | Example |
boot | Start booting (shortcuts: F10, CTRL + x). | The command is issued without arguments. |
cat | Write the contents of a file to standard output. | cat (hd0,1)/boot/grub/grub.cfg |
configfile | Load a configuration file. | configfile (hd0,1)/boot/grub/grub.cfg |
initrd | Load the initrd.img file. | initrd (hd0,1)/initrd.img |
insmod | Load a module. | insmod (hd0,1)/boot/grub/normal.mod |
loopback | Mount an image file as a device. | loopback loop0 (hd0,1)/iso/image.iso |
ls | Display the contents of a directory or partition. | ls (hd0,1) |
lsmod | Display a list of loaded modules. | The command is issued without arguments. |
normal | Activate the normal module. | The command is issued without arguments. |
search | Search for devices. Option –file searches for files, –label searches for labels, –fs-uuid searches for filesystem UUID. | search -file [filename] |
set | Set an environment variable. If issued with no arguments, the command prints the list of all environment variables and their values. | set [variable-name]=[value] |
Repairing Boot Error
The GRUB Rescue prompt and the Boot Repair tool are the two methods covered in this tutorial for fixing GRUB boot problems.
1: Thru Grub Terminal
1: To display the environment variables, use the set command without any arguments:
set
According to the example output, GRUB is configured to start from the (hd0, msdos3) partition:
2: The ls programme displays a list of the disk’s accessible partitions.
ls
The partition list appears in the output.
To locate the partition holding the boot directory, use the ls command.
the partition named ls
The (hd0, msdos1) partition’s boot directory is displayed in the example.
3: Change the root variable’s value to the boot partition. The illustration employs the division titled (hd0, msdos1).
place root= (hd0, msdos1)
4: Launch the standard boot mode.
insmod default
5: Launch the standard boot mode.
normal
You can provide more intricate commands in the usual mode.
6: Use the Linux command to load the Linux kernel.
root=/dev/sda1 ro Linux /boot/vmlinuz-4.2.0-16-generic
7: Execute the command boot.
boot
Now, the computer boots correctly.
2: Via Live picture
Using a Linux live image to boot from an external device is another option to resolve your GRUB boot problems.
1: Get a live Linux installation first. The ISO image of Ubuntu 20.04 is used in this example.
2: Write the Linux image to an SD card or USB flash drive using a programme like Etcher.
3: Start the computer after inserting the bootable media.
4: Choose On the welcome screen, try Ubuntu.
5: Establish an internet connection when the live system starts up.
6: To add the repository for the Boot Repair programme, open a terminal and enter the following command.
Adding the ppa: Yannubuntu/boot-repair repository with sudo
Once the repository has been added, hit Enter.
7: Repository updates.
apt update with sudo
8: Set up the Boot Repair programme.
install boot-repair with sudo apt
9: Use the terminal to launch the Boot Repair tool.
boot-repair
10: Choose the suggested repair.
Await the tool’s completion of bootloader repair.
3: GRUB configuration file update
How to Use Grub Rescue to Fix Linux Boot Failure? Check the GRUB configuration after the system has successfully booted up.
Execute this command:
update-grub
4: GRUB Reinstallation
To reinstall GRUB on your Linux machine, adhere to the methods listed below.
1: Mount the OS installation partition. The /mnt directory is where the /dev/sda1 partition is mounted in the example.
mount /dev/sda1 /mnt with sudo
2: Connect the respective directories in the /mnt folder to the /dev, /dev/pts, /proc, and /sys directories.
sudo mount --bind /dev /mnt/dev &&
sudo mount --bind /dev/pts /mnt/dev/pts &&
sudo mount --bind /proc /mnt/proc &&
sudo mount --bind /sys /mnt/sys
3: Setup GRUB.
grub-install -root-directory=/mnt/dev/sda sudo
4: Following a successful installation, unmount the folders.
sudo umount /mnt/sys &&
sudo umount /mnt/proc &&
sudo umount /mnt/dev/pts &&
sudo umount /mnt/dev &&
sudo umount /mnt
Conclusion
After reading this article, you ought to be able How to Use Grub Rescue to Fix Linux Boot Failure? or Boot Repair tools to resolve your Linux boot issue. Read How to Use fsck Command for another method to resolve your boot-related problems.