Tuesday, August 02, 2011

UUID mixup leads to boot fail

This is a complicated topic that no title can do justice to so let me explain.
It started with my moving the root partition of LinuxMint on the EeePC 901 from one partition to another with the help of GParted which I've already reported.
After moving the root partition, I ran update-grub from Ubuntu (Ubuntu's Grub2 is in the MBR and I use this to boot everything). However, LinuxMint wouldn't boot from Grub as there was a problem with the UUIDs in /boot/grub/grub.cfg
Here below are the two lines in this file where the UUID is needed and, of course, both should be the same.

search --no-floppy --fs-uuid --set=root 26a42e8d-d057-412b-b1ae-7330400c4997
linux /boot/vmlinuz-2.6.38-8-generic root=UUID=26a42e8d-d057-412b-b1ae-7330400c4997 ro quiet splash vt.handoff=7

However, in the grub.cfg generated by update-grub, the second UUID was actually the UUID of the old partition from which I had moved the root partition.
This was easily rectified by copying the first UUID to the second. Then LinuxMint booted without problem.
Today I returned to Linux Mint and found that Mint wouldn't boot again, dropping me to a busybox shell. A single user mode boot also did not complete but pointed me to the non-existence of the root partition.
Oh boy, that sounds familiar.
When I checked in Ubuntus's /boot/grub/grub.cfg, sure enough two different UUID's were shown in the LinuxMint stanza. What's more the second one was the UUID of the old partition, from which the Mint root was moved, and which no longer exists.
So where was update-grub getting this defunct UUID from?
I spent quite some time researching this but eventually found that LinuxMints own /boot/grub/grub.cfg (Mint's bootloader sits in its own root partition and, indeed, is quite unnecessary) used only the UUID of the old, and now dead, partition as I had never updated grub in LinuxMint.
Once I had run update-grub in Mint the grub.cfg was corrected and contained the correct UUID. What's more, after this, updating Grub in Ubuntu now provided the correct UUID in LinuxMint's stanza.
So, it seems that updating grub in Ubuntu searches LinuxMints grub.cfg to get the UUID for the Linux line in the LinuxMint stanza of Ubuntu's grub.cfg.
Strange that it doesn't object to using two different UUIDs for the same partition device.
In any event, the lesson to be learnt is to update grub in the moved partition (assuming it to be a root partition) before updating Grub in the MBR.

No comments:

Post a Comment