Monday, 12 September 2011

Recovering Gentoo linux after changing hard disk channel

On my system I have two hard drives a 40 gb old one [reminiscent of the times when that much was enough] and a new one of 1tb. Initially both of them where on channel 2: the new one was the master disk while the old one was the slave disk. When I installed Gentoo, I tried

fdisk -l

and found the new one to be /dev/sda while the old one was /dev/sdb. So while installing grub, I assumed the following mapping:
hd0 --> sda --> 1tb hdd
hd1 --> sdb --> 40gb hdd

Grub was installed successfully and dual boot was working fine. [For those readers who are curious about getting a dual boot system, the best place is to look at the handbook.] However, when I got a new DVD writer, the old hard disk was connected at channel 0 as slave and the new one was connected at channel 2 as master. My BIOS was set to boot from the new one and Windows booted fine but I could not boot into Gentoo. So, I decided to fix it and chrooted into my Gentoo installation from the minimal install iso that I had put on to a usb stick using unetbootin. [Recently there have been questions about the performance of unetbootin. I would just like to add that when I tried unetbootin from Windows it failed me thrice with different distributions. However, when I tried it from linux, it worked just fine.]

From within the chrooted environment, I ran

fdisk -l

and found the old hard disk was now sda and the new one was sdb. So, I assumed the following mapping while reinstalling grub:
hd0 --> sda --> 40gb hdd
hd1 --> sdb --> 1tb hdd

However, when I rebooted, grub showed error 17. A quick look at Grub error collection shows that I had somehow got root(hdX, Y) wrong. While talking about the issue on #gentoo, I found that hd0 is actually the drive the BIOS is set to boot from. So, my assumed mapping was incorrect and it turned out that hd0 was being mapped to 11tb hard drive. So, I went into the BIOS and changed it so that the correct mapping was followed.

P.S. To know more about grub read this article.

No comments: