GRUB bootloader: OS recovery

GRUB is the bootloader for most versions of the Linux operating system. With it, you can organize multi-boot and use several different OSs on the same computer. For example, you can work under Linux, and after a reboot, relax using the game features of Windows. Unfortunately, in the life of any user there are times when, for various reasons, it may be necessary to restore the bootloader. In this article, we will talk about the most likely causes of this phenomenon and how to restore normal computer operation.

OS bootloader features

Let's see what function the bootloader performs on the computer and what its damage leads to. As part of the operating system, it takes the baton from the base I / O system and continues to run it after the POST test. Its role includes preparing equipment for work, loading the kernel of the OS and transferring further control to it.

grub recovery

Thus, damage to the bootloader leads to a situation in which, after the initial hardware test, even if it completed without errors, the computer cannot find the kernel of the operating system and, therefore, start it. The OS will give you an error message about the inability to detect the boot configuration.

The main causes of damage can be:

  • installing a second OS on one hard drive;
  • reinstalling Windows in a multi-boot system;
  • error in the process of partitioning the hard disk.

GRUB role

To be extremely precise, modern versions of Linux do not use GRUB, but its more modern version of GRUB 2. To get rid of an inconvenient number in the name, the old version was called GRUB Legacy, and the new one is called the name familiar to Linux users. We will not depart from the established designation.

bootloader recovery

After understanding the terminology, consider the possibilities of GRUB. The Windows 7 bootloader, the most common in the Microsoft family, as well as all its other versions, is not able to correctly identify file systems of other OSs. GRUB copes with this task.

Therefore, if both Linux and Windows are installed on your computer, bootloader recovery must be performed for Linux. Otherwise, you will not get the opportunity to choose the OS when you turn on the computer.

OS installation procedure

As we have already said, the Windows 7 boot loader will not be able to detect the presence of another OS on the computer. Since this feature has long been known, there are several unwritten rules for multi-boot systems:

  • installing multiple versions of Windows is performed from the youngest to the oldest;
  • Linux is always installed second after windows.

Failure to comply with the second rule leads to the need to perform a GRUB recovery. Windows installed after Linux simply erases its bootloader, replacing it with its own, perceiving the disk space occupied by this OS as unallocated. Of course, it is not always possible to follow the rules, even when you know them. Nevertheless, understanding the role and functions of GRUB, it is not difficult to restore it.

Training

Before starting any operation with a computer, preliminary preparation is necessary. Restoring GRUB is no exception. Ubuntu was the first operating system in which it became the default bootloader. We need a LiveCD with this version of Linux, whose bit depth matches the version installed on your system.

grub windows recovery

LiveCD is a removable media version of Linux that can boot without using a computer hard drive. Initially, this option was used to get acquainted with the capabilities of this operating system. By downloading from it, the user could study the OS without having to install it and get a general idea of ​​it without any risk.

This disk can also be used if the GRUB bootloader is damaged. Recovery using it is described in detail in the free community documentation. Changes in the architecture of laptops, namely the gradual disappearance from new models of CD / DVD drives, lead to the fact that the term LiveCD has received a broader interpretation. It is understood not only as a laser disk, as it was originally, but also as a USB flash drive.

grub ubuntu recovery

Before using such a disk, make sure your system is ready to boot from removable media. To do this, you will need to boot into the BIOS and check the installed priority of the boot devices.

Recovery

When all the preparatory operations are completed and the system is ready, we boot from the LiveCD. Since such disks actually represent a ready-made operating system, you will see an ordinary desktop of your chosen version of Linux. Further actions will require minimal command line skills for this OS. In the main menu, you need to find and launch the “Terminal”. In the Linux command line window that opens, enter the command:

sudo fdisk -l

As a result, you will get a list of hard disk partitions in which you need to select the one on which Linux is installed. On most systems, this will be sda5. If in your case this section will be different - replace the number in its designation with the necessary. Next, mount it using the following command:

sudo mount / dev / sda5 / mnt

The next step is to install the new bootloader:

sudo grub-install --root-directory = / mnt / dev / sda

After a few seconds, the following notification appears on the command line:

Installation finished. No error reported.

grub recovery

Therefore, you have successfully written the new GRUB bootloader. Recovery is almost complete. Perform a reboot and this time boot into the Linux that is installed on the hard drive. There is one final update operation left. Open the “Terminal” again and enter the command:

sudo update-grub

This action will need to be confirmed with the root password. After its execution, you get a fully functional and correctly determining the installed GRUB boot loader GRUB. Recovery is complete, you can use the computer in the usual mode.

Finally

As you can see, there is nothing complicated in this operation. All actions are performed in normal graphics mode. You can consider yourself to have passed the “baptism of fire” and entered the Linux army.

Source: https://habr.com/ru/post/C45763/


All Articles