Search This Blog

Sunday, December 6, 2009

Grub2 - Dual Boot, SATA Drive Problems

Update Dec. 15, 2009

A recent update has once again hosed Grub. The system only comes up in "rescue" mode which is like telling a user to "Go Fish".

Super Grub will boot Ubuntu but the Windows partition is unrecognized. Supergrub will work sporadically so you have to reboot numerous times to get a menu.

IMO, its too early to move to Grub 2 unless you have a very vanilla setup.

Dec. 23 Update

I tried in vain to correct the problems I was having with Grub 2 and repeatedly failed. What I became good at though was recovering using the Supergrub disk.

The final solution that worked was to uninstall Grub2 and then reinstall it, trying only one boot device at a time.

In my case the first boot device failed to work so I uninstalled Grub 2, reinstalled it and tried again. The second boot device worked fine.

Needless to say Grub 2 is an adventure.



DEC. 7, 2009 - Original instructions.

I'm guessing that for many users who have a straightforward single boot Ubuntu system the upgrade from Grub 1.whatever is probably fairly easy.

I run a dual boot, fairly heavy duty machine at home that was hand built. About a year ago I updated the motherboard from an AMD to a P5Q Intel board and outfitted it with a brand new SATA drive.

In order to boot the machine, I found myself having to use the older Maxtor XP drive as the boot drive partitioned awkwardly for Ubuntu and Grub. The SATA drive just gives me huge disk space.

So in reading a recent article about the release of a new, improved grub implementation, I foolishly decided to perform the upgrade procedure as described in an optimistic article [DON'T DO THIS!]:

sudo aptitude install grub-pc
Chainload from menu.lst? <-- Yes
Linux Command line: <--enter

Next enter:

sudo upgrade-from-grub-legacy

Here you'll be confronted with a series of questions about which boot device to use.

I simply keyed enter and nothing seemed to happen so I tried a few keys that I thought would work and finally got the program to end.

In rebooting the machine I was confronted with a Grub Error 11: Unrecognized device string

I fixed the Error 11 problem to be confronted with an Error 15 problem.

I fixed the error 15 problem and wound up with a grub command line terminal that seemed to refuse grub commands.

It took me two (busy) days to recover.


First the official instructions can be found at the Ubuntu wiki. These are worth reading before following anyone else's advice. But even these instructions have their blind spots.

And speaking of blind spots there are a half dozen recovery instructions that are equally lame and misleading.

What follows are instructions that I hope are both comprehensive and accurate for most complex dual-boot environments and a series of fixes for those of you caught in the errors.



Bios Setup Preliminaries (may be unnecessary for very vanilla machines):

For users with more than one hard drive, you will need to know which hard drive is used to initially boot the machine.

Secondly, you'll need to know if the boot sequence recognizes all the drives. In the case of my SATA drive, it showed up in the bios setup as a drive but was not recognized as a boot device.

This information can be found in the bios setup when you restart the machine (check your motherboard documentation).

If you are already in a GRUB2 error mode, be sure the boot sequence has a CD or DVD or USB bootable device preceding your primary boot drive.

If your machine has a secondary hard drive that does not show up as a bootable device option in bios, shut off the machine, disconnect the power, wait till the motherboard is wholly powered down, and carefully disconnect that drive [this is temporary]. Since the SATA drive isn't recognized by GRUB at boot time, it cannot be allowed to be a factor in our debugging or corrective action process.



Pre-installation Backup Preliminaries:

Before trying to install GRUB2, navigate to the boot disk's boot folder and copy everything in it to a finger drive or removable media. this can prove to be a system saver later.



Installation Instructions and a WTF Rant:

First open a command terminal and run; sudo os-prober. This will identify the /dev/sdxx boot device. For example Ubuntu might be on /dev/sda0. This will later show up in the update grub command sequence.

BTW: the results of this command can differ if the secondary SATA drive is connected. It can add irrelevant and inaccurate results.

As I said before, the most accurate GRUB2 installation instructions are here. And while the instructions are accurate, they describe a procedure that is decidedly user unfriendly and perilous.

The "sudo apt-get install grub2" instructions are intuitive and work fine. However it is the "sudo upgrade-from-grub-legacy" process that defies any sensible logic. The documentation warns;
NB! You have to use the spacebar to mark the choice here. DO NOT go on without doing this. It WILL result in your system showing error 15 and being unable to even show a boot menu. If you are running a dual boot system with WindowsXP or Vista, you might have to do additional fixes after upgrading to get it to work.

If this has already happened to you you can fix this by following the directions in the Error 15 section on this page.

So let me get this straight. If for some reason I am not privy to this warning, the program goes right ahead and hoses me! Unbelievable!

When the user is actually running this command, nowhere does the stone age program provide this warning nor any instruction of how to make it work! So as a user, if I just hit the enter key assuming the default drive or drives are chosen, I'm not only wrong but thrown into a state of machine anarchy and personal chaos.

The interface used for the GRUB2 activation is entirely unjustifiable. First, if a primitive interface is really necessary, then it should tell the user to use the space bar to pick a boot device [the sdx device os-prober identified]. Secondly, if a device IS NOT CHOSEN then back out gracefully, offer the user a second chance, or simply rename the grub.cfg file to something else so the the user is not thrown into the error abyss.



Climbing out of the GRUB2 error abyss:

A user who tries upgrading to GRUB2 and gets thrown into a non-bootable machine state has a number of remedies. Booting from an Ubuntu install disk will get you back into the machine to poke around. If the disk and directories are still intact then restoring the /boot/ backup material is something that will restore you to your original state.

If you've no backup and gotten lost in corrective actions that don't work, you can burn an iso cd of a program called SuperGrub from here.

Rebooting using SuperGrub can restore your system so that you can go back into the /boot/grub directory and attempt fixing the appropriate files as documented on the Ubuntu wiki.



Making the system whole after correction

Shut off the machine. Disconnect the power. Reconnect any disconnected drives.