GRUB (Grand Unified Bootloader) is a widely used bootloader in Linux-based operating systems. It is responsible for loading the operating system kernel and starting the boot process. Losing GRUB can be a frustrating experience, but the good news is that it can be quickly recovered with some basic knowledge and tools.
In this article, we will discuss the various methods to recover lost GRUB bootloader in Linux, step by step.
Method 1: Use Boot Repair Disk
Boot Repair Disk is a powerful tool that can automatically fix various boot-related issues, including recovering lost GRUB bootloader. It is a Linux-based live CD/USB that can repair boot-related problems in Windows and Linux.
Here are the steps to use Boot Repair Disk to recover lost GRUB bootloader:
- Download the Boot Repair Disk ISO file from its official website and create a bootable USB drive using any available method.
- Boot your computer using the Boot Repair Disk USB drive.
- Once the Boot Repair Disk environment is loaded, select the “Recommended repair” option from the main menu.
- Follow the on-screen instructions and wait for the process to complete.
- After the process is completed, restart your computer and check if the GRUB bootloader is recovered.
Method 2: Use GRUB Rescue Mode
GRUB Rescue Mode is a built-in feature of GRUB that can be used to recover lost GRUB bootloader. It is a command-line interface that provides basic commands to recover the bootloader.
Here are the steps to use GRUB Rescue Mode to recover lost GRUB bootloader:
1. Boot your computer using a Linux Live CD/USB.
2. Open a terminal and run the following command to find the partition on which your Linux installation is located:
sudo fdisk -l
3. Identify the partition that contains your Linux installation and mount it to a temporary directory:
sudo mount /dev/sdaX /mnt
Replace “sdaX” with the actual partition number of your Linux installation.
4. Install GRUB on the mounted partition using the following command:
sudo grub-install --boot-directory=/mnt/boot /dev/sda
Replace “/mnt/boot” with the actual boot directory of your Linux installation and “sda” with the actual disk on which your bootloader should be installed.
5. Reboot your computer and check if the GRUB bootloader is recovered.
Method 3: Use Live CD/USB and Chroot
Chroot is a Linux command that can be used to change the root directory of a process. In the context of recovering lost GRUB bootloader, it can be used to access the Linux installation and install GRUB.
Here are the steps to use Live CD/USB and Chroot to recover lost GRUB bootloader:
1. Boot your computer using a Linux Live CD/USB.
2. Open a terminal and run the following command to find the partition on which your Linux installation is located:
sudo fdisk -l
3. Identify the partition that contains your Linux installation and mount it to a temporary directory:
sudo mount /dev/sdaX /mnt
Replace “sdaX” with the actual partition number of your Linux installation.
4. Mount necessary directories using the following commands:
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
Change the root directory to the mounted partition using the following command:
sudo chroot /mnt
1. Install GRUB using the following command:
sudo grub-install /dev/sda
Replace “sda” with the actual disk on which your bootloader should be installed.
2. Update GRUB configuration using the following command:
sudo update-grub
3. Exit from the chroot environment using the following command:
exit
4. Reboot your computer and check if the GRUB bootloader is recovered.
Tips to Prevent Losing GRUB Bootloader
Although recovering lost GRUB bootloader is possible, it is always better to prevent it from happening in the first place. Here are some tips to help you prevent losing your GRUB bootloader:
- Keep your system updated: Regularly updating your system and software can help prevent issues that could lead to GRUB bootloader loss.
- Avoid dual-booting with Windows: Dual-booting with Windows can sometimes cause issues with the bootloader, so it is better to avoid it if possible. If you need to dual-boot, follow the proper installation procedure and take the necessary precautions.
- Backup your data regularly: Always keep a backup of your important data on an external drive or cloud storage. This way, even if you lose your GRUB bootloader or face any other issue, your data will be safe.
- Use a reliable antivirus software: Using a reliable antivirus software can help prevent malware infections that could cause bootloader issues.
By following these tips, you can significantly reduce the chances of losing your GRUB bootloader and keep your system running smoothly.
Conclusion
Recovering lost GRUB bootloader in Linux is a common issue that can be fixed easily with the help of Boot Repair Disk, GRUB Rescue Mode, or Live CD/USB and Chroot. These methods provide a step-by-step approach to recover the lost bootloader and get your system up and running again. Remember to always have a backup of your important data to avoid losing it in case of a bootloader issue.
📕 Related articles about Linux
- How to Mount Remote Filesystems using SSH: A Comprehensive Guide
- How to Remove an Existing User in Linux
- How to Get CPU Speed on Linux
- How to Create tar.gz File Archive in Linux
- How to backup MBR in Linux
- How to extract RAR file in Linux