GRUB Rescue to the Rescue!

Sun 28 August 2011
By mute

So I'm on travel and have my netbook, my blackberry, and CompacFlash reader. I was trying out a few different operating systems on the CF for this WRAP.2E router board. Of course I got into the quick habit of doing fdisk, wipe partition table, yada yada. WELL OF COURSE I use '/dev/sda' the last time instead of '/dev/sdc'. I realize this before I rebooted though. I grabbed TestDisk and fixed that easy. I still have *NOTHING* on hand to fix it in case I reboot and problems arose, so I didn't plan to.

Well, Sunday I got up at 5:30am and eventually was so bored I wanted to boot into XP to try the Sun Wireless Toolkit 3.0 to recompile jmIrc (for my blackberry to get on freenode). What did I see? NO MBR! :O OK so let's try to boot the CompatFlash I made for the router. Oh man, it is setup for serial console. Nothing on my screen..

Didn't I have a bootable Linux on my actual blackberry memory card? I plug that in. Oh, I must have deleted it. But I had the "grub rescue>" prompt. *HOPE* Now I have no idea why grub went the way of modules except maybe an exercise of mental masturbation, but I don't like it. You end up needing most of them and it's not much size-wise..

So usually if you get a "grub rescue>" it's because of a wrong root/prefix. But mine was because I didn't have a /boot/grub at all on the phone. I had no success using the /boot/grub of my actual Ubuntu install since it was a different version I suppose. So I use BBSSH to ssh to my server. It happened to have a full grub complement installed, even though it's Xen... So I symlink /boot into my website directory and start downloading the important looking .mod's..

I thought I could grab normal.mod and type "insmod normal" and be good. Didn't work, grabbed more stuff, still no work. Finally saw a moddep.lst. Oh that was great. I want "linux.mod" and "ext2" at least. So I get the dependencies worked out and finally it boots directly to a normal "grub>" prompt. I had problems with ext2 still and tried different vmlinuz/initrd combos from my blackberry without success at getting much anywhere... Finally realized ext2.mod was enough (in lieu of needing say an ext4.mod), it just required fshelp.mod (whyyyy!).

So I was able to boot directly into my Ubuntu install then. Thank goodness I had at least fixed my partition table somewhat before rebooting, and thank goodness I still had some of grub left on my blackberry.

I hexdump -C -n 512 /dev/sda and of course it's pretty empty. Found /dev/sda5 had GRUB boot record in it.. went ahead and did a grub-install /dev/sda though. Haven't rebooted again but I'm confident it'll work, and if not I just have to simply type 'linux' and 'initrd' with my blackberry grub now and get back here.

So while I didn't play with jmIrc today, I did find a good way to waste four hours of an otherwise very boring weekend (Hurricane Irene hit us all Saturday, which was pretty uneventful as well.)

The whole thing would have been much simpler if I had kept Puppy Linux on my blackberry. Unfortunately it was probably deleted to make more room for pr0n (which i also deleted weeks ago). :o