loading...

Linux Mint – Reinstalling GRUB

How to use the Docker Compose command

GRUB, which stands for Grand Unified Bootloader, is the program that is responsible for booting Linux Mint. If, for some reason, it becomes damaged, you won’t be able to boot your machine and will get errors. This could be for any number of reasons, such as Windows overwriting the Master Boot Record ( MBR), a failed cloning attempt, or even nonfailure incidents such as simply wanting to make something bootable, such as a flash drive.

If you want to install GRUB on a different disk, the grub-install command, shown in the following command line, should be all that you need:


sudo grub-install <device>

For <device>, simply type the device on which you’re attempting to install GRUB. If you want to reinstall GRUB on your main drive, <device> will typically be /dev/sda, but you should always verify your devices before installing or reinstalling GRUB. The following command will list your drives:


sudo fdisk -l

Note

Take note that when you install or reinstall GRUB, you don’t specify a partition. This is because the boot sector is written before the partition table, so in order for GRUB to be bootable on a device, it must live at the beginning of the drive. Thus, you’d type /dev/sda instead of using /dev/sda1 for the device when working with GRUB.

However, what if you were unable to boot at all? One of the most common reasons why someone may reinstall GRUB is due to a booting issue. If you can’t boot, you can’t issue the grub-install command required to make it boot again. Actually, there is a way of doing this. If you boot from live media (such as the installation disc you created for Mint), you can access your installation and repair it. As mentioned several times in this tutorial, keep a live disc handy at all times; you never know when you might need it. Linux live discs are even useful for recovering Windows systems, among other uses.

To repair GRUB from a live DVD, first insert it and start your computer. In the case of Mint’s live media, you’ll have a fully functional graphical environment to work with. This graphical environment will also allow you access to the system’s hard disk and Linux installation. The first step is to mount the hard drive that contains the installation you would like to repair. The simplest way to do this is to open the Nemo file manager, and click on your system’s hard drive. Doing so will automatically mount it just before it shows you the contents. If a graphical environment won’t load, you can mount your main hard drive with the following command:


sudo mount /dev/sda1 /mnt

Note

The previous command assumes that your root partition is /dev/sda1. To be sure, issue sudo fdisk -l to get a listing of your partitions.

After executing the mount command, the contents of your root partition will now be located in /mnt. Feel free to navigate to the /mnt folder, and check the contents to be sure that you’ve mounted the appropriate device.

Next, you can reinstall GRUB. The following command will do the trick:


sudo grub-install –root-directory=/mnt/dev/sda1

Again, adjust /dev/sda1 to the device on your system. After the command executes, reboot your system (type reboot in the terminal window, or click on Reboot through the desktop environment’s Quit menu), remove the disc when prompted, and see if your machine now boots as expected. As long as you typed the commands properly and used the proper values, there shouldn’t be any issues with GRUB.

Comments are closed.

loading...