Skip to main content
Restore the Linux bootloader in Rescue
Last update:

Restore the Linux bootloader in Rescue

The main boot loader for Linux operating systems is GRUB. In case of problems you can restore the boot loader using LiveCD — boot into Rescue mode.

In the Live system, you must mount all partitions in a pre-created folder (e.g. /mnt) similar to how they were mounted in the main system.

To restore the bootloader:

  1. Start the system from the LiveCD and open the terminal.

  2. Locate the root partition where the system is installed using the command fdisk (in the output, find the section with type Linux filesystem):

    fdisk -l

    If the system is installed in a non-LVM partition, the root partition will be in the /dev/sda*:

    • in a partition using LVM — /dev/mapper;
    • if the partitions are on a software RAID array — /dev/md* (the mount is performed to the appropriate array);
  3. Suppose the primary system has a root partition /located in /dev/sda2 and section /bootlocated in /dev/sda1. Mount the partitions in /mnt:

    mount /dev/sda2 /mnt/
    mount /dev/sda1 /mnt/boot

    If you are using a UEFI bootloader, mount the EFI partition as well:

    mount /dev/sda3 /mnt/boot/efi

    Specify /dev/sda3 — EFI partition.

    With the command cat /mnt/etc/fstab you can see the mount point in the host OS, as well as the UUID of the disk and map it to the UUID of the disk in the Live image.

  4. Mount the directories /sys, /proc, /dev:

    mount --bind /sys /mnt/sys
    mount --bind /proc /mnt/proc
    mount --bind /dev /mnt/dev
  5. Navigate to the main system environment using chroot:

    chroot /mnt

    If an error occurs, use the command with /bin/bash:

    chroot /mnt /bin/bash
  6. If GRUB is not installed on the disks, install it. If no installation is required, skip to step 7. GRUB must be installed on all disks from which you plan to boot. For example, if you are using RAID0 for your boot partition:

    grub-install /dev/sda
    grub-install /dev/sdb

    Depending on the number of devices, there may be more disks in the RAID.

  7. To generate a GRUB configuration file, type:

    update-grub

    or

    update-grub2
  8. Get out of the environment chroot:

    exit