/ Dev / sda1 * 2048 41940991 20969472 83 Linux
In most of the cases you will see that you have a Linux system partition sda5, sda4, or whatever sdaX. That means that your hard disk (as it’s seen above) it’s sda.
In any case we recommend to check hard disk size next to Disk /dev/sdX at the output’s beginning so that you make sure that you select the exact hard disk that boots initially in your machine.
Now we are going to install grub back to the MBR, which it is what most people to do.
In the next command you will need to replace sda with your hard disk.
Either you run:
sudo grub-install /dev/sda
(where you might have to write your user password blindly or not) as a admin user or:
grub-install /dev/sda
as root user from a terminal.
The most probable output for the command is:
Installation finished. No error reported.
That means that the installation was successful. When you reboot Grub menu should be alive again.
Although strictly not needed is a good idea at this point to re-create the Grub configuration files. Either because you have added a Windows partition or because your Gnu/Linux partition is in a different partition (That latter case usually needs /etc/fstab to be edited too but that would be another howto.).
There are different ways of updating Grub configuration depending on you using Grub legacy, current Grub (Grub2), Debian based distributions, Fedora based distributions or custom distributions. We will try to cover most of the options. We will start just by the ones we think are the most common ones.
As I said this before this step is strictly not needed so you can skip it. Just go back to this step if after Restoring grub step (and rebooting) you see your former grub but somehow your Grub menu does not work as expected. You know, Gnu/Linux or Windows is not booting as it always happened.
Another alternative is using Rescatux which has an Update Grub option which tries to take care of all the possible situations.
If your distribution does not use sudo please run the command without the initial sudo and as a root user.
sudo update-grub
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo grub-mkconfig -o /boot/grub/grub.cfg
Although there are some unofficial scripts for this task the official way of changing them is:
.