Saturday, August 23, 2008

Grub Error 24: Attempt to access block outside partition

I made a few mistakes on my media box playing around with packages that had more dependencies than I originally thought... At any rate, I decided it would make more sense to just reinstall and start fresh than to try and pick up the pieces. After going through the reinstall, formatting my OS hard drive and installing Ubuntu, it asked for a reboot. When it restarted, I hit the following Grub error:

Error 24: Attempt to access block outside partition

After doing a ton of searching online, I finally figured out that this was a problem with my menu.lst file that Grub uses to boot. In my case, it was attempting to boot off the wrong HD with the line:

boot (hd4,0)

To correct this, I had to do a temporary and then a permanent fix. The temporary fix is needed to get Ubuntu to boot at all, and because I wasn't able to figure out an effective way to edit the menu.lst file without being able to boot into Ubuntu in the first place...

So, for the temporary fix, when you start (or reboot) your computer, wait for the Grub loading stage and hit escape to interrupt the countdown (usually 3 seconds by default) and enter the grub menu.

Once in the Grub menu, hit 'e' to begin editing. Look for the line that starts with 'boot' and make sure it's set to 'boot (hd0,0)'. If it's not, go down to that line if you're not already on it and hit 'e' to edit that line. Change 'hdX' (where X is any number NOT 0) to 'hd0' and hit enter to accept the change. Then hit 'b' to boot with those settings.

*NOTE* If your boot line was set to (hd0,0), check here for other alternatives.

Once you've done this, you should be able to boot Ubuntu. Now you need to make sure you don't have to do this every time! To do this...

Open a terminal and type:

'sudo vi /boot/grub/menu.lst'

This will open your menu.lst file for editing. (If you're not used to editing in vi, you can also try gedit by typing 'gksudo gedit /boot/grub/menu.lst')

In either case, once you have the file open, navigate down past all the commented lines (lines starting with '#') towards the bottom of the file. There you'll see three sections, one to load Ubuntu, one to load Ubuntu in recovery mode, and one to run the Ubuntu memtest. In all three of these sections, there's a line similar to:

root (hdX,0)

In all three sections, edit this line to be:

root (hd0,0)


This will ensure that Grub boots off the right device from now on!

Good luck!