Saturday, May 31, 2008

Regrowing Grub

The scanning need being important I had to revert to XP. Post install, ofcourse, the grub menu was replaced by XP's boot menu.
The first procedure that I tried was to use a live CD to try to recreate the lost Grub. I recalled seeing such an option in one of the distros. Probably Sabayon. Since FC8 and Kubuntu 8.04 were the only ones that I had at that moment, and neither had the required boot option, I searched online for a solution.
One solution was to use the grub-install command in the Linux rescue mode. This mode is available in most live distro's, though it was absent in Kubuntu. Usually adding "linux-rescue" to the boot option is also adequate, but Kubuntu did not allow changing boot options either. The webpages providing the solution mentioned that the rescue mode would mount the linux partition under mnt/sysimage, and from there the grub-install command from the boot/grub/directory could be accessed. Unfortunately, the FC8 rescue attempt failed with the error that the installation could not be mounted. Without that the grub-install command would not work since the paths were not accessible. So running the command gave a /boot/ path not found error.

More hunting revealed an alternative way. This involved using the setup command after running grub. This too required a Live distro and the rescue mode. At the command prompt, run the grub command, and you get the grub prompt.
There run "find /boot/grub/stage1", to find the path to the directory. This will return the partitions containing the said folder. This would be in the format (hd0,1).
With this info run the root command to locate the menu files. "root (hd0,1)"
The run the setup command to reinstall grub. The format is "setup (hd0)".

After a reboot, I found that grub was installed, but I did not see the menu, just the grub prompt. So I looked around a bit in the grub help, and found the configfile option. Then at the grub prompt, I entered configfile /boot/grub/menu.lst" and voila the menu appeared. After loading the GUI ( I was on PCLinux) I redid the grub installation from the control panel. Now all installations are back to normal, including the new XP.

No comments: