How to install GRUB bootloader on master boot record on Ubuntu or Mint

Question: My Ubuntu fails to boot from disk after a clean installation. I suspect GRUB bootloader was not properly installed during Ubuntu installation for some reason. I would like to repair GRUB bootloader. How can I re-install GRUB bootloader on my Ubuntu?

In Linux, master boot record (or MBR) is a reserved space in disk storage which stores an OS bootloader as well as disk partition table. If GRUB bootloader is not loaded properly, you can try re-installing GRUB bootloader on MBR. Here is how to install GRUB bootloader on MBR on Ubuntu or other Ubuntu-derivatives such as Linux Mint.

It's assumed that /dev/sda is the disk which contains a boot partition.

First, using fdisk command, verify that the boot partition (typically the first partition) in /dev/sda is tagged as "bootable". If the partition is bootable, it should show "*" under "Boot" column in the fdisk output.

$ fdisk /dev/sda

If the boot partition is not bootable, mark it as "bootable". You can press "a" on fdisk to toggle a bootable flag. After changing a bootable flag, make sure to press "w" to write the change to disk.

After this, use the following commands to install GRUB bootloader.

$ sudo grub-install --boot-directory=/boot /dev/sda
$ sudo update-grub

Finally, reboot and check if it can boot from disk.

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

Leave a comment

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

Current ye@r *