21 November 2010

How to restore Linux loader after installing Windows without Live-CD

Often having both Linux and Windows installed on the same PC I face trouble when after reinstalling Windows my Linux loader (GRUB\LILO\whatever) got erased with nasty one from M$. Before I always had to look up some live-CD distro to boot and restore GRUB. Today I was too lazy to do that - I had no suitable CD (or maybe it's time to throw away my CD drive) and after a quick look through the web I've found GRUB4DOS. So what magic does it provide? Here is the trick - GRUB4DOS allows you to install it from withing your running Windows instance, it boots up a GRUB-like stuff where you can select another partition to boot from. Basically you then boot to your broken GRUB record, then boot up your Linux distro and then having complete environment you just restore your broken GRUB MBR record. Easy, ha! To install the GRUB4DOS we don't even need to perform any dangerous manipulations with MBR. You just download grub4dos or grubinst package from http://sourceforge.net/projects/grub4dos/files/, copy grbldr from the package to your system drive root (e.g. C:\grbldr) and add following line to boot.ini:
Now you just need to reboot the PC, boot your Linux distro and reinstall GRUB On my ArchLinux I did the following:
$ sudo grub-install --root-directory=/ \(hd0\)
This installed GRUB to the MBR of my first hard drive and put staging files under /boot/grub directory.
Post a Comment