- you may need to use a live CD/USB somewhat similar to that of your ‘master’ OS, where your boot loader configuration is stored. This is due to the technique we use to re-run the GRUB installer.
Boot the Live CD/USB
- Start the Live CD up as normal. Don’t choose to install the OS if prompted, you want to come to a full live desktop to run the specific commands we need.
Identify your Partitions
- Use G-parted for GUI based info or,
- open a Terminal program and use the following command”
This will list all of the partitions on all the devices on your system. Under the ‘System’ column, you can see all of the partitions labelled as ‘Linux’. This won’t show you the difference between data and OS partitions, so is less useful in a more complex partition layout.If you can work out where your Linux is from this, note down the information under ‘Device’.
Mount the Partition
- First get bash root access
$ sudo bash
- We will first make a folder in which the partition is mounted and then do the mounting. Replace the device string /dev/sda5 (my case) with the device string that you identified earlier.
# sudo mkdir /mnt/system
# sudo mount /dev/sda5 /mnt/system
- The next process we are going to perform is to temporarily change the root directory of our terminal (chroot), so that we can run the GRUB installer directly from the hard drive. It won’t even realise it’s not running from the real system
On Ubuntu and other sudo-based distros, we must first do this to become root fully (sudo is not enough here).
# sudo -i
Doing the chroot
- The GRUB installer requires to read the devices on disk directly in order to write the GRUB boot record back onto the system properly. It therefore needs a working copy of /dev, inside the mounted directory.
# mount -o bind /dev /mnt/system/dev
- Next, we can run chroot:
# chroot /mnt/system
Run the GRUB Installer
- All we need to do now is to simply run the GRUB installer, which plonks the GRUB boot record back on the hard disk and gives us back all of our choices.
# grub-install /dev/sda
- If you need to install GRUB elsewhere (such as a different disk or a specific partition), change /dev/sda. In most cases, just leave this as-is.
That’s it,GRUB should be re-instated on disk. You can now simply close your terminal, reboot the machine safely and everything should be back to normal.