Monday, July 06, 2009

GRUB install problems...

I've been fighting recently with a virtual linux box, trying to get the size of the virtual hard disk reduced (and as you know, MS Virtual PC doesn't shrink Linux hard disks very well). My answer was to create a new vitual blank hard disk, repartition it, recover the data, restore GRUB, and I'd be away...

Trouble is, it wasn't that easy. Every time I tried to use GRUB to setup the MBR, I got various errors - the long ang short of it was that GRUB couldn't see the files on the partition, even though I'd chroot'ed, and could see them perfectly.

The solution to my problem was twofold. Firstly, I hadn't created the partition properly. GRUB only works with partitions that use a inode size of 128, so I had to create the ext3 partition with...

mkfs -t ext3 -I 128 /dev/sda2

The next stage (after I recovered the data) was to chroot to the mounted /dev/sda2, and run GRUB in interactive mode, to setup the MBR - but still no luck, no files could be found. The reason was twofold

  1. The linux recovery system CD used had /dev/hda as the IDE disk, not /dev/sda, so I changed my linux recovery system CD to one that used the same devices as my virtual linux system.
  2. The sys, proc and dev points mounted as chroot did not match my current rescue system, so I needed to do the following before chrooting...
mount -t ext3   /dev/sda1 /mnt
mount -t proc proc /mnt/proc
mount -t sysfs sys /mnt/sys
mount -o bind /dev /mnt/dev
chroot /mnt /bin/bash
Once this was all done, I was able to run the GRUB interactive setup correctly. Interestingly, the inode size of 128 can also affect LILO too...

For more information, please look at http://wiki.archlinux.org/index.php/Reinstalling_GRUB.

No comments: