Friday, February 20, 2009

Ubuntu: GRUB Error 22, Error 15

This is an update on a previous post discussing issues with GRUB Error 22 and Error 15. It started with Error 22. In this case, though, I got a short version of the error message: I got simply "Error 22" instead of "Error 22: No such partition." I was not sure whether this was because I was now working with Ubuntu Intrepid Ibex 8.10 rather than Hardy Heron 8.04, or whether there was instead some other reason. It had been a while, but it appeared that I might not have understood, last time around, that the Error 22 problem was, in a sense, a Windows problem, not an Ubuntu problem. Or maybe it wasn't, that time. But this time, it was. I solved the problem by simply running the Recovery Console (i.e., boot with the Windows XP CD and choose R; just hit Enter for the Administrator Password) and doing a three-step sequence: FIXMBR, FIXBOOT, and then FIXMBR again. Then Exit. Once I did that and rebooted, I got a screen that said, "Please select the operating system to start" and gave me a choice between Microsoft Windows XP Professional and UNetbootin. This calls for another explanation. UNetbootin is installed by Auto Super Grub Disk (ASGD). ASGD is a freeware Windows program that, basically, makes it easy to get your GRUB going again at least in some cases, so you don't have to spend a lot of time screwing around with the regular Super GRUB Disk (SGD) (available from that same website or elsewhere). I had installed ASGD because I was already at this problem for a while before I decided to take these notes. So I chose the UNetbootin option. It ran, and then said, "FIX OF BOOT FAILED." So ASGD was not going to solve this particular problem for me. It said "Hit return to continue," which I did, and then it said,

USE: NORMAL SUPER GRUB DISK RESCATUX (COMMING SOON OR LATER) LINUX LIVE CD THE FORCE, LUKE.
Very funny, that last line. At this time, Rescatux was vaporware. So I tried rebooting with Super GRUB Disk (burned to a CD). In the English Super Grub Disk option, I chose the Gnu/Linux (GRUB) option. It gave me "Error 15: File not found" and "SGD has NOT succeeded." I rebooted from the Ubuntu 8.10 live CD (i.e., the program CD that I had used to install Ubuntu). I clicked on Places > Computer > UBUNTU to mount the hard drive, where the installed file system was (as distinct from the file system contained on the live CD). UBUNTU was the name I had given to the partition where I had installed Ubuntu. Now I had a symbol next to UBUNTU, there in File Browser, indicating it was mounted. I went back to the main menu and chose Applications > Accessories > Terminal. At the prompt in Terminal, I typed "sudo -i" (always without the quotation marks, unless otherwise indicated) and hit Enter. This logged me in as "root," i.e., as administrator. Then I typed "nautilus." This gave me another File Browser session, but this one had the advantage of having root powers. In this browser, I went to UBUNTU > boot > grub > menu.lst. Someone said that said an easier way would have been to just type "sudo gedit /boot/grub/menu.lst," but this seemed to open the wrong copy of menu.lst. I killed File Browser, so as to set Terminal free to do other stuff. (Probably could have opened another session of Terminal instead.) Following advice from the thread just cited, I typed "ls /boot" but was not sure what this was telling me. (In another thread, incidentally, someone said they fixed their Error 22 by rearranging SATA drive cables.) I found the GRUB Page within the Illustrated Dual Boot Website. I went to their Troubleshooting Section > Error Messages from GRUB > Error 15 instructions. They cited three different possible problems. First, maybe my menu.lst was specifying the kernel or initrd.img file incorrectly. I had restored this Ubuntu installation from an Acronis True Image backup. I liked TrueImage, but it had caused me some difficulty when restoring Ubuntu on another occasion. This time, I was seeing a discrepancy between menu.lst and the contents of the /UBUNTU/boot folder, viewed in File Browser. The /boot folder seemed to contain two different Ubuntu kernels -- not only kernel 2.6.27-7-generic but also 2.6.27-11-generic. But it did seem like at least the 2.6.27-7-generic one should boot, so I doubted that was the problem. To double-check that, I followed the advice to type "ls /boot" and see what that gave me. Almost everything it listed seemed to relate only to the config-2.6.27-7-generic option. So I guessed that the appearance of only the 2.6.27-7-generic option in menu.lst was not a problem. The second problem they considered was that maybe the Universally Unique Identifier (UUID) line in menu.lst was wrong. The idea of the UUID was apparently to identify a kernel by a unique code, so it didn't matter which order you plugged your hard drives in (so you wouldn't have to change menu.lst, every time you rearranged drives or partitions, to indicate that the Ubuntu installation was now located at (hd2,0) or whatever. Well, but of course, in my case it wasn't working. But this second option seemed to apply in situations where someone was using an older version of GRUB, and that wasn't the case here -- everything was newly installed from an 8.10 CD. The third scenario was that maybe some of the files in /boot/grub were missing or corrupt, such that I would have to completely delete those files and restore clean copies. The instructions for this seemed to say I would first need to boot the system using SGD. This wasn't good, because I wasn't able to do that. I also needed to know where my Ubuntu files were, and normally that would have been no problem, but in this case I was confused; they did not seem to be where I thought they were supposed to be. I decided to start again from the beginning, or at least from one beginning. I rebooted without anything in the CD drive. This gave me, again, the choice between booting WinXP or UNetbootin. I chose WinXP. It booted. Fine and dandy. I rebooted, and this time I chose UNetbootin. It gave me the FIX OF BOOT FAILED message again. So we had confirmed that ASGD was not the solution. Booting again with SGD, I went back into the Gnu/Linux option and chose Boot Gnu/Linux Directly. This just got me Error 15 again. After hitting Enter, I found myself at a menu and chose the Miscellanea > Boot Gnu/Linux > different Root and Boot Partition (Manual). But I couldn't get that to work either. Still in SGD, I tried Advanced > Gnu/Linux (Advanced) > GRUB > UnInstall GRUB (MBR). I wasn't sure which drive to uninstall it from, so I chose the first one. It said, "SGD has succeeded!" I tried again with the second drive. Same thing. Ditto on drives 3 and 4. I rebooted into WinXP and ran ASGD again. Incidentally, I had told WinXP's Disk Management to run disk tests on all partitions on reboot, which seemed especially advisable because, in response to one of the Ubuntu commands I had entered, I had seen a message that said, "Partition table entries are not in disk order." But the Windows disk check did not seem to make any difference. After wandering around in SGD's wonderful tools and confusingly redundant menus for quite a while, I stumbled upon Boot & Tools > Boot Master Boot Record (MBR). I tried it with drive 1 (hd0), and it gave me the GRUB menu with just WinXP and UNetbootin. I did a Ctrl-Alt-Del and tried it with the second drive; it froze after showing me a half-dozen lines of code, ending with "chainloader +1" and "boot." Third and fourth drives: same thing. This appeared to indicate that it was supplying its own code to get the ball rolling, but that there was no MBR on those drives to continue. So drive 1 was the only game in town. Now it was just a question of how to fix the MBR on drive 1 to include Ubuntu. Focusing on drive 1, then, I went into SGD's Gnu/Linux > Fix Boot of Gnu/Linux (GRUB) again. This time, I looked at all of the lines it was showing me. Its Error 15 seemed to be indicating that it was not finding the stage1 files for GRUB. The suggestions I was seeing, at this point, were heavy on the "delete Ubuntu and start over" approach. But I wanted to learn how to address this problem on the fly, without having to devote hours to rearranging data, reinstalling, etc. So one suggestion was to boot with the alternate Ubuntu CD and install GRUB that way. I had an alternate CD for 8.04, but not 8.10. I gathered there had been some changes to GRUB or menu.lst etc., so I downloaded and burned the 8.10 alternate. While that was downloading, I tried something else. I booted with the regular Ubuntu CD, and used the procedure described above to make sure the UBUNTU partition on the hard drive was mounted. (That may have been unnecessary.) Then, as advised by some community documentation, I typed the following in Terminal:
sudo -s grub find /boot/grub/stage1
That gave me a response of "(hd2,4)." That's where my Ubuntu partition was. So then I typed this:
root (hd2,4) setup (hd2,4) quit
Then I rebooted. UNetbootin still didn't fix the boot. I tried again with SGD. When I used it to try to boot the Ubuntu partition, it again gave me "Error 22: No such partition." I gave up and reinstalled Ubuntu using my TrueImage backup. SGD still didn't do it. I tried the Manual Boot option. That called for some of the same step as before:
sudo -s grub root (hd2,4) chainloader +1 boot
Unfortunately, the "chainloader +1" step gave me an error: "Invalid or unsupported executable format." Another possibility was to type this, also at the grub> prompt:
configfile (hd2,4) /boot/grub/menu.lst
This got the error message, "Filename must be either an absolute pathname or blocklist." Then I realized I had neglected to mount the UBUNTU drive as described above. So I did that. But I still got the same error messages for these chainloader and configfile commands. Now I thought that perhaps I had the pathname wrong. I navigated around the drive using CD commands, starting with "CD /" and then naming folders (e.g., "CD media") until I got down to the one that contained stage1 (above). So now I tried again with what I thought might be the correct absolute pathname:
configfile (hd2,4) /media/disk/boot/grub/menu.lst
This gave me "syntax error near unexpected token 'hd2,4'." The website mentioned above gave me the option of entering commands from the menu.lst file manually, but I wasn't sure how they worked or what I was doing, so I decided instead to try booting with the alternate CD, which I had finished downloading and burning by this time. I chose the "Rescue a broken system" option. After answering a number of questions, mostly with default answers, I chose "Reinstall GRUB boot loader" as my first rescue operation. Next, I named /dev/sdc5 as the bootable device where I wanted the GRUB boot loader installed. But I got "Unable to install GRUB in /dev/sdc5." So I went back and tried "(hd0)" instead. That failed too. Next, I tried /dev/hda2. Another failure! So this was why things had not been working: it could not install GRUB anywhere. I found some instructions for recovering GRUB within an older version of Debian Linux. Those instructions were essentially: (1) within the "Rescue a broken system" option on the Ubuntu Alternate CD, choose the option that says, "Execute a shell in ." (2) In the shell, I typed "fdisk -l" (that's an L, not a 1) to make sure my Ubuntu installation was at hd2,4. Then I typed
grub root (hd2,4) setup (hd2) quit exit
Now, this seemed to be more or less what I had done before. But this time, I guess the Alternate CD made the difference, because when I rebooted, I had a regular GRUB menu, with Ubuntu and Windows on it. I tried the Ubuntu option, and it ran!

1 comments:

Anonymous

SGD 0.9774 version has 256-byte inode support and works well fixing Ubuntu 8.10 (I have some doubts now about booting Linux but I have not checked it).
You were just using an outdated version.

I think that Auto Super Grub Disk has not 256-byte inode support and I have to update it. :(

It was a nice grub adventure. ;)

adrian15