The GRUB bootloader is a small, essential program that manages the boot process for multiple operating systems on your computer.
It can be corrupted or deleted during events like a Windows installation, preventing access to your other operating systems. Fortunately, you can restore the GRUB bootloader using the remaining configuration files located in your Linux root partition.
Steps to restore deleted or corrupted GRUB bootloader in Linux:
- Boot your computer using a Linux Live CD or USB drive.
- Get into Live CD mode if available.
For Ubuntu installer, click on the Try Ubuntu button.
- Open terminal application.
If no Live CD mode available, press <ctrl> + <alt> + <f2> keys to get to the terminal. For Ubuntu, the default username is ubuntu and the password is empty (just press enter at the password prompt).
- Identify the Linux partition containing the functional GRUB configuration.
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 1.9G 1 loop /rofs loop1 7:1 0 89.3M 1 loop /snap/core/6673 loop2 7:2 0 53.7M 1 loop /snap/core18/941 sda 8:0 0 20G 0 disk └─sda1 8:1 0 20G 0 part sr0 11:0 1 2G 0 rom /cdrom
- Create a temporary directory to mount the Linux partition.
$ mkdir tmp
- Mount the Linux partition to the temporary directory you created.
$ sudo mount /dev/sda1 tmp/
- Mount the /dev and /proc folders to the mount point of the Linux partition.
$ sudo mount --bind /dev tmp/dev $ sudo mount --bind /proc tmp/proc
- Use the chroot command to change the root directory to the Linux partition.
$ sudo chroot tmp/ root@ubuntu:/#
- Reinstall the GRUB bootloader using the existing configuration files.
root@ubuntu:/# grub-install /dev/sda Installing for i386-pc platform. Unknown device "/dev/sda1": No such device Unknown device "/dev/sda1": No such device Unknown device "/dev/sda1": No such device Unknown device "/dev/sda1": No such device Unknown device "/dev/sda1": No such device Unknown device "/dev/sda1": No such device Installation finished. No error reported.
- Exit the chroot environment.
root@ubuntu:/# exit exit
- Shut down the computer.
$ sudo poweroff
- Remove the Live CD or USB drive.
- Boot the system.
Author: Mohd
Shakir Zakaria
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Discuss the article:
Comment anonymously. Login not required.