OK, in the last post, I had moved my partitions around substantially, so we were obviously in for a few problems booting. To recap, the new layout looks like this:
- /dev/hda1 – 20Gb – Linux main system (moved and enlarged)
- /dev/hda2 – 100Mb – /boot partition (moved)
- /dev/hda4 – 1 Gb – swap partition (moved)
- /dev/hda3 – Extended partition containing
- /dev/hda5 – 17 Gb Data partition (enlarged)
- /dev/hda6 – 17Gb /home partition (newly created to house all the VMs)
The first problem was getting the thing to boot up. The MBR was still on the boot sector of the drive, but it was telling the computer to boot from the wrong sector. I pulled out the Mint / Ubuntu install CD and booted from that.
From the desktop (running on the live CD), I opened a terminal and did this:
This asks grub to locate its files on all available partitions: the first find command didn’t work but the second one did. It returned hd(0,1), which is the first hard disk, second partition. Grub starts from zero, while linux hard disk enumeration starts from a and 1, so hd(0,1) equals hda2. So, armed with this information we do:
This tells grub that it should boot partition (hd0,1) and that it should reinstall itself on the MBR of hd0 (=hda).
Now we can reboot from the MBR on the hard disk, and grub will be able to find its files. But we have a separate boot partition, so when we boot, it still won’t be able to find the root file system. So now, when we boot the first time, we can interrupt the boot process and hit ‘e’ to edit the boot command. Grub is in the boot sector on hd(0,1) and the rest of the filesystem is on hd(0,0), so we need to tell grub where the filesystem is. The boot command reads:
/boot/vmlinuz-2.6.22-14-generic root=/dev/hda2 ro quiet splash
so we change it to
/boot/vmlinuz-2.6.22-14-generic root=/dev/hda1 ro quiet splash
And also, I know that I need some extra options to boot this darn Thinkpad R51e, so actually I changed it to
/boot/vmlinuz-2.6.22-14-generic root=/dev/hda1 ro quiet noapic ec_intr=0 splash
You can actually try this a few times until the thing boots correctly. Once you hit the magic combination, remember what it was, and then when you’ve booted successfully, you just edit /boot/grub/menu.lst to make the changes permanent.
All of this is a bit of a heart-stopping few minutes, but at the end of the day, all your data is backed up and if the worst comes to the worst, you can restore it … right?
But I was in for a couple of surprises. The first surprise comes from the fact that Ubuntu doesn’t mount its disk partitions with /hda1, hda2, etc, but it uses a UUID. There are some good reasons for this — it makes it easy to move partitions around. However as I’d cloned the partitions when I moved them, there were two partitions with the same UUID.
Here are the basic steps as I recall them, although this was some time ago now:
- Find out the UUIDs of each partition with eg
sudo vol_id -u /dev/hda1
- Create a new UUID for the hda1 if necessary with eg
sudo tune2fs -U random /dev/hda1
- Edit /etc/fstab and enter the correct UUIDs against the correct partitions.
There is more information on this to be had in the Ubuntu forums. A search on UUID will get you a bunch.
Final surprise. When I run gparted to check the partitions, I can see that the root partition, hda1 is mounted as / and /dev/.static/dev
Although this hasn’t caused me any problems, it still unnerves me. Let me know if you have a solution to this.
So there we have it. A Windows to Linux migration in only a few weeks! Actually next time I could do it in a day or so, but I wanted to test everything out and take it slowly. Possibly a smarter way of doing it would be to buy a new hard disk, but I was too cheap for that. 🙂