When grub dies

This article was written on 2011/04/02 which never got published  😦

I was living happily with my windows xp and OpenSuse. But then my need to be with Android went strong and I tried looking for the resource on android build and “Android Source Code page ” said they test on Ubuntu and on any other distro same should be possible. With that same hope I started to install requried tools and libraries on OpenSuse and found that it would take some time which I had short.

Going Back to Ubuntu

Ubuntu was back and it needed to be usable fast. Mine was compaq laptop where HP had created recovery drive on HDD with Vista. With my frustration towards Vista which I had removed I got to know that my recovery partition was no longer usable; with lot of search on google I found that if deleted directly the recovery partition could create and issue while boot. I went on to follow the idea presented on how to remove the HP recovery partition. With download of HP recovery manager if found that it doesn’t recognize the my recovery partition, immediately i went on with deleting the partition and going ahead.

According to PC standards (IBM PC) primary partitions cannot be more that 4 in a system this includes our logical partition with is considered as primary as whole. So now take away the drive space from OpenSuse, to my surprise the Ubuntu live CD took lot of time to work as live CD , using Gparted we can resize and move partition space along with features of creating new drives.

Now the stage is set for Ubuntu ubuntu-9.10-desktop-amd64.iso is installed on the emptied partition space as one of the main boots, with this I have 3 boot time OS’s and 1 Virtual Machine inside Windows XP. Finally once installed I tried a check on all OS. first I boot windows partition it went into system check and most of the links were restored along with corruption of MBR at hd0,0 by rewriting of grub area with windows default.

finally triple OS boot option but without actually able to boot into any. The screen would get into “Grub loading…” for a very long time and finally falls back on grub rescue> prompt. with little search on Internet I found that we can get back boot option using below commands;

grub rescue> find /boot/grub/stage.cfg

grub rescue

grub rescue> root (hd0,0)

grub rescue> setup (hd0)

and restart.

This option would work if your boot partitions of being recognized but in my case the grub itself was of minimal mode with out support to any commands.

next was to use live CD, so I boot with live CD and for my surprise it didn’t have grub , then downloaded grub using

$sudo apt-get install grub

then

$sudo setup-grub (hd0)

which actually installs grub on HDD on initial memory space.

rebooted again to get some working grub after which I tried above commands to make my grub understand that Ubuntu was available in HDD but in vain. It was not able to recognize the drive.

Next step was to boot to either windows XP or OpenSUSE manually as I had grub understanding the they are their.

grub> root (hd0,1)

grub> chainloader +1

grub> boot

the above commands did the miracle of booting windows and its was not broken. so the next step was to boot OpenSUSE using the same method. One of the differences with grub was that OpenSUSE was older grub (meaning version less than grub2 with /boot/grub/menu.lst) and Ubuntu was with new grub (meaning version greater than grub2 with /boot/grub/grub.cfg). So when I booted OpenSUSE It had its own grub menu alive indicating that new grub was not yet part of the show. I inspected grub folder , grub.cfg and found that initially soon after installation the grub had recognized all the partitions, but windows boot did damage the MBR.

I tried booting Ubuntu using chainloader but it didn’t work. next option was to try booting Ubuntu using full manual method i.e specifying kernel path and initrd paths.

grub> root (hd0,2)

grub> kernel /boot/vmlinuz-2.6.13-14-generic root=UUID=<UUID of the hd0,2> ro quiet splash

grub> initrd /boot/initrd.img-2.6.13-14-generic

grub> boot

I was expecting it to boot but it went and sat on busybox shell. next attempt was to try with absolute path.

grub> root (hd0,2)

grub> kernel /boot/vmlinuz-2.6.13-14-generic root=/dev/sda2 ro quiet splash

grub> initrd /boot/initrd.img-2.6.13-14-generic

grub> boot

And the miracle happened. I saw Ubuntu logo. The I was inside Ubuntu. So the next step was to secure my boot menu in its place.

$sudo setup-grub (hd0)

and updated the menu

$sudo update-grub

and I am back fully functional on Ubuntu. verified Windows XP and OpenSUSE. Now its cool…………

Advertisements

About preetammn

engineer trying to figure out the world, people and machines.
This entry was posted in LINUX and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s