Restore the Linux bootloader in Rescue
The main boot loader of 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 should mount all partitions to a pre-created folder, such as /mnt
, similar to how they were mounted in the main system.
To restore the bootloader:
-
Start the system from the LiveCD.
-
Open the CLI.
-
Print information about the partitions on the available disks:
fdisk -l
-
Find the root partition where the system is installed. In the disk information you got in step 2, find the partition with the
Linux filesystem
type.The root partition is in/dev/sda*
, if the partitions are on a software RAID array —/dev/md*
(mount to the corresponding array). -
Suppose your main system has a root partition
/
located in/dev/sda2
and a/boot
partition located in/dev/sda1
. Mount the partitions to/mnt
:mount /dev/sda2 /mnt/
mount /dev/sda1 /mnt/boot -
If you are using a UEFI bootloader, mount the EFI partition:
mount /dev/sda3 /mnt/boot/efi
Specify
/dev/sda3
as the EFI partition.Use the
cat /mnt/etc/fstab
command to see the mount point in the host OS, as well as the UUID of the disk and match it to the UUID of the disk in the Live image. -
Mount the
/sys
,/proc
,/dev
directories:mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev -
Navigate to the main system environment:
chroot /mnt
If an error occurs, use the command:
chroot /mnt /bin/bash
-
If GRUB is not installed on the disks, install it.If no installation is required, skip to step 7.GRUB should be installed on all disks from which you plan to boot.For example, if RAID0 is used for the boot partition:
grub-install /dev/sda
grub-install /dev/sdbDepending on the number of devices, there may be more disks in the RAID.
-
To generate a GRUB configuration file, type:
update-grub
or
update-grub2
-
Exit the
chroot
environment:exit