How To Install Grub

Table of contents:

How To Install Grub
How To Install Grub

Video: How To Install Grub

Video: How To Install Grub
Video: How to install grub bootloader manually 2024, May
Anonim

When installing multiple systems on a computer, there is a problem with managing the boot sector of the hard disk. For example, if Linux was first installed on the computer, and only then Windows was installed, then the OS from Microsoft will erase the GRUB loader and when the computer starts it will be impossible to select the system, and Windows will boot by default.

How to install grub
How to install grub

Necessary

any Linux LiveCD

Instructions

Step 1

To repair the Grub bootloader, you need a LiveCD or a Linux boot disk. The Ubuntu CD, which is both a live and an installation disc at the same time, works best.

Step 2

Boot from the LiveCD. After the system has finished loading, launch the Terminal ("Menu" - "Applications" - "Default apps" - "Terminal") and enter the command:

sudo grub.

Sudo allows you to get superuser rights to execute a given command, and a grub prompt starts the shell. This will put you in the bootloader shell and the appropriate grub> prompt will appear.

Step 3

Next, enter the following command:

find / boot / grub / stage1.

This query will return the value of the location where the bootloader is located (for example, hd0, 1 or hd0, 6). The MBR boot sector contains only a small amount of information about grub, and with find you find all the files you need to install.

Step 4

Enter the received section number in the following query:

root (hdValue, value).

Step 5

Then install the files to the boot partition of your hard drive:

setup (hd0).

This request installs the bootloader to the hard drive, and since the second parameter is missing, the installation is performed directly on the MBR.

Step 6

Then exit the grub shell:

quit.

Step 7

There is a second way to solve the problem. Boot from the Live CD and mount your hard drive in the most convenient location. For example:

mount / dev / hda / media / hard.

Step 8

After that, make a request through the Terminal:

sudo grub-install / dev / hda --recheck --root-directory = / media / hard.

The recheck option is used to check the correctness of the installed file /boot/grub/device.map, and in case of an error, the command fixes it.

Step 9

Remove the LiveCD, restart your computer and you should be able to boot into your installed system again.

Recommended: