Friday, August 12, 2011

GRUB and Reinstalling GRUB : Debian/Ubuntu

GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn. 

And playing around with GRUB to get multiple Operating Systems indexed and to make them available for booting is as awesome as it could get. 
The sheer scalability GRUB has to offer in terms of the number of OS'es it can index is superb. I have gone up to six different operating systems at one point of time, and currently am running five. And that doesn't still represent the number of OS'es that can be multi-booted via GRUB. It is only constrained by the space on your hard drive!

My current Grub entry
While trying the tricks of installing multiple operating systems, if care is not taken the latest OS will overwrite the GRUB and if it ain't a GRUB based bootloader (as would be the case when the last OS is M$ Windoze, or sometimes even Redhat!) the entries of other OS will be lost. 

GRUB on the top of Ubuntu/Debian are the best to retrieve and index all the installed OS. 

Here are the steps for reinstalling GRUB at the MBR for an Ubuntu/Debian distro. 

  • Get hold of a Live CD/Live USB stick with either Debian or Ubuntu
  • After entering the Live user environment, spot the ext4 partition of the Ubuntu/Debian
  • To get to know the partition where the hidden Ubuntu/Debian is installed, usually   
sudo fdisk -l
would suffice. Or gparted is another tool which could be of help
  •  Once you've got to know the ext4 partition, then mount it in the Live environment 
sudo mount /dev/sda5 /mnt (assuming that the ext4 partition of the hidden Ubuntu/Debian install is on sda5)

  • Now, reinstall GRUB :)
sudo grub-install --root-directory=/mnt /dev/sda
(GRUB will be installed on the MBR of sda)

And you're done!

  • Now, boot into your Ubuntu/Debian distro which was running on sda5 (in the example) and run  
sudo update-grub

This will generate a new grub.cfg file as shown in the image above.

No comments:

Post a Comment