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:
-
Start the system from the LiveCD and open the terminal.
-
Locate the root partition where the system is installed using the command
fdisk
(in the output, find the section with typeLinux 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);
- in a partition using LVM —
-
Suppose the primary system has a root partition
/
located in/dev/sda2
and section/boot
located in/dev/sda1
. Mount the partitions in/mnt
:mount /dev/sda2 /mnt/
mount /dev/sda1 /mnt/bootIf 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. -
Mount the directories
/sys
,/proc
,/dev
:mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev -
Navigate to the main system environment using
chroot
:chroot /mnt
If an error occurs, use the command with
/bin/bash
:chroot /mnt /bin/bash
-
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/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
-
Get out of the environment
chroot
:exit