How to reinstall GRUB in Ubuntu

Reinstall Grub Ubuntu

Among the Linux bugs that can cause us the most fear, I think there are two: the one that can make us panic includes that same word in its name, and the bug is called “kernel panic”. But as someone who has used Linux for many years and used to dualboot, and never seen a live kernel panic, the ones I've been most afraid of historically have been GRUB crashes. If this has happened to you, and you use an operating system based on Canonical's, this article will teach you how to reinstall ubuntu grub.

DUB it the program which is responsible for loading and managing the startup process, boot in English. It is the most widespread bootloader in Linux distributions. A bootloader is the first software that runs when a computer boots, and it loads the operating system kernel and then the kernel starts the rest, like the shell, display manager, graphical environment and everything else. No GRUB, no party.

Reinstall Ubuntu GRUB to fix minor issues

There may be several reasons to reinstall Ubuntu's GRUB. Some of them may be reset or reboot GRUB, in the sense that it returns to its original state if we are experiencing failures with the software.

If we can enter the operating system and want to reinstall Ubuntu's GRUB, the process is quite simple. It would be enough to open the terminal and write:

sudo update-grub

With the above command, if there is a problem with your installation, it will try to fix it automatically. If we've done any customization, it should go away, but the problems should go away too. This would be what in other processes is known as a soft reset or soft reset GRUB.

To complete the process we will have to reboot the operating system, and it will be then when we will see or stop seeing what has been pissing us off recently.

How to reinstall it if I can't get into the operating system

If we cannot enter the operating system, the situation is already somewhat more tricky. For reasons like this it is worth always having an installation USB or Live USB with the operating system that we have installed on our computer. If we have several, it is worth creating a USB with windy with which we can start different Live Sessions. But the important thing is that we have at least one USB with the same system as our computer to solve problems like this.

Because to reinstall, or here better to say repair, the Ubuntu GRUB if we cannot enter the operating system, we will have to do it from a Live USB; will be the easiest way. The process would be as follows:

  1. We assume we already have a Live USB, so we boot from it. If we don't have it and we have another computer where we can create it, we first create it and then start from it.
  2. When it tells us what to do, we choose the "Try Ubuntu" option, nothing to choose to install or we will not enter the Live Session.
  3. Once we enter, the same thing: first we select the language in which we want the interface and then we choose “Try Ubuntu”, which is what will make us enter the Live Session.
  4. We open a terminal, something that can be done with the key combination Ctrl+Alt+T.
  5. With the following command we will find out the partition in which Ubuntu is installed:
sudo fdisk-l
  1. We mount the Ubuntu partition in the /mnt directory with this command (changing the X and Y to those of drive and partition, such as sda1):
sudo mount /dev/sdXY /mnt
  1. Now you have to mount the special system partitions:
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; donate
  1. In the next step and with the following command, we will change the root directory to the mounted partition:
sudo chroot /mnt
  1. Next we reinstall GRUB on the hard drive (as before, changing the X to the drive letter, such as sda:
grub-install /dev/sdX
  1. We update the GRUB configuration:
update-grub
  1. In the next few steps we'll work our way back, starting by exiting the chroot session with "exit" without the quotes.
  2. Now we unmount the special system partitions:
for i in /sys /proc /run /dev; do sudo umount "/mnt$i"; donate
  1. Finally, we restart the computer. To do this, we do not have to forget to remove the installation USB, or else it will re-enter from it and we will not see the changes.

Reinstall the operating system

Of course, someone who stumbled across this article hoping to fix things by repairing GRUB wouldn't expect a reinstall of the entire operating system to do the trick, but sometimes much can be fixed with a reinstall.

Reinstalling something is not installing it from scratch. Instead, you install important software by replacing the core of the operating system with the packages in their original state. Therefore, it is an option, and a very valid one, since it would fix the GRUB problem and Our data and documents should not be lost.

When we are going to install Ubuntu, if we already have Ubuntu installed, it gives us the option to install on the existing system, and this will do more or less the same as when we restore a mobile, with the difference that the content of the /home folder will remain. Installed programs will disappear, but not your settings. Therefore, after an installation that seems to be from scratch, when we install any program, the configuration that we had before reinstalling the system should be there. And our documents too.

And although this is usually the case, for users who want to be more comfortable with this type of problem, it is worth making several partitions when installing the operating system, as explained in this article. Ubuntu needs the boot and root partitions no matter what. Both are created automatically if you leave the default installation, but it's a good idea to create two more: the swap partition and the /home partition. In order not to lose our information, the really important one is /home. Then, if we want to reinstall with all the guarantees, we have to choose "More options" and then format root (/), but not /home.

I hope this tutorial has helped you to reinstall Ubuntu GRUB, or at least that you were able to use it again without losing too much information.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.