Usually on each disk there is an MBR (master boot record) and when the computer is turned on, the BIOS accesses it for information for further download. On Linux systems, GRUB is used as the boot loader, I will write about the recovery options of which below.
You can see the version of GRUB using the command:
1) First option.
We start the system with LiveCD/USB, for example in the Ubuntu Desktop image, in addition to the installation, it is possible to start the system.
Open the terminal, for this press Alt+F2 and enter the command:
Let’s see the list of sections:
sudo fdisk -l
Suppose the partition with the loader on /dev/sda1, connect it to the directory /mnt:
sudo mount /dev/sda1 /mnt
If software RAID is used, then:
mount /dev/md2 /mnt
mount /dev/mapper/vg0-root /mnt
And install grub in MBR with the following command:
sudo grub-install --root-directory=/mnt /dev/sda
You may also need to update the grub menu:
sudo update-grub --output=/mnt/boot/grub/grub.cfg
Done, grub is restored!
2) The second option through chroot.
Again, you need to start the system from the LiveCD/USB and open the terminal.
We will admit the partition with the loader together with the main partition on /dev/sda1.
We will connect it to /mnt, and also we will tie several necessary directories:
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
If /boot finds on a separate partition, then connect it to /mnt/boot, for example:
sudo mount /dev/sda2 /mnt/boot
Let’s move on to chroot:
sudo chroot-prepare /mnt
sudo chroot /mnt
In case of an error, we type:
grub-install --recheck /dev/sda
It is possible still so:
grub-install --recheck --no-floppy /dev/sda
Exit the chroot:
Disconnect the sections:
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt
Similarly /boot if it is separate:
sudo umount /mnt/boot
Restart the computer:
3) The third option, using recovery mode.
Let’s see what partitions are the next command (the numbering of disks starts with 0, and the partitions with 1, that is, the disk /dev/sda can be called for example hd0, and the partition /dev/sda1 – hd0,1):
We indicate this section:
And let’s check if there is grub:
If there are, we load the modules:
If the section is in the format btrfs, then execute a few other commands:
After the commands, Grub will start and determine which operating systems are installed.
Finally, run Linux and from the root user install grub on the correct disk, for example /dev/sda:
Restart the system and check: