The GRUB bootloader is responsible for managing the startup of your operating system and allowing you to select between different installed operating systems. When GRUB becomes corrupted or deleted, often due to installing another OS like Windows, it can prevent you from accessing Linux or other systems installed on your computer. In this case, recovering GRUB is required to regain access to your operating systems without reinstalling them.

Restoring the GRUB bootloader involves using the configuration files that remain on your Linux partition. By booting into a Linux Live CD or USB drive, you can access the terminal and reinstall the GRUB bootloader to the correct partition. This ensures that you can restore the boot process and regain access to your system.

The recovery process is efficient and works for most Linux distributions that use GRUB. The key steps are to identify the Linux partition, mount it, and reinstall the GRUB bootloader. Following these steps will restore the bootloader and allow you to access all installed operating systems again.

Steps to restore GRUB bootloader:

  1. Boot your computer from a Linux Live CD or USB drive.
  2. Get into Live CD mode if available.

    For Ubuntu installer, click on the Try Ubuntu button.

  3. Open the terminal in the live environment.

    If no live environment is available, use <ctrl> + <alt> + <f2> to access a terminal. For Ubuntu, the default username is ubuntu and the password is empty (just press enter at the password prompt).

  4. Identify the Linux partition containing the 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
  5. Create a temporary directory to mount the Linux partition.
    $ mkdir tmp
  6. Mount the Linux partition to the temporary directory.
    $ sudo mount /dev/sda1 tmp/
  7. Bind the /dev and /proc directories to the mounted partition.
    $ sudo mount --bind /dev tmp/dev
    $ sudo mount --bind /proc tmp/proc
  8. Use the chroot command to switch to the mounted Linux partition.
    $ sudo chroot tmp/
    root@ubuntu:/#
  9. Reinstall the GRUB bootloader to the correct disk.
    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.
  10. Exit the chroot environment.
    root@ubuntu:/# exit
    exit
  11. Shut down the computer.
    $ sudo poweroff
  12. Remove the Live CD or USB drive.
  13. Boot the computer to verify that the bootloader has been recovered.
Discuss the article:

Comment anonymously. Login not required.