Monday, January 3, 2011

More detailed Wubi grub analysis

A fresh Wubi 10.04.1 install will fail to boot after updating package grub-pc. When you select Ubuntu, the computer reboots, hangs or drops you to a grub prompt. This is nothing new - many people have been affected by this bug.

A fresh Wubi install has two files in /boot/grub: grubenv and grub.cfg. That is all. When you update grub-pc, the script grub-install runs and this copies all the grub modules etc. into /boot/grub. This results in a modified grub.cfg as some of the scripts directly reference objects in /boot/grub, and the result is a Wubi that cannot boot.

For a fresh 10.04.1 install, the differences in grub.cfg before and after updating grub-pc are:
> insmod ntfs
> set root='(hd0,2)'
> search --no-floppy --fs-uuid --set 80e4e195e4e18daa
> loopback loop0 /ubuntu/disks/root.disk
> set root=(loop0)
> if loadfont /usr/share/grub/unicode.pf2 ; then
> set gfxmode=640x480
> insmod gfxterm
> insmod vbe
> if terminal_output gfxterm ; then true ; else
> # For backward compatibility with versions of terminal.mod that don't
> # understand terminal_output
> terminal gfxterm
> fi
> fi
> insmod ntfs
> set root='(hd0,2)'
> search --no-floppy --fs-uuid --set 80e4e195e4e18daa
> loopback loop0 /ubuntu/disks/root.disk
> set root=(loop0)
> set locale_dir=($root)/boot/grub/locale
> set lang=en
> insmod gettext

By resetting /boot/grub back to normal, the grub.cfg that is generated boots fine:
sudo mv /boot/grub /boot/grubold # backup /boot/grub
sudo mkdir /boot/grub # make a new /boot/grub
sudo cp /boot/grubold/grubenv /boot/grub # copy only required file
sudo update-grub # regenerate grub.cfg

That's 10.04.1...

With 10.10, there are some script changes in Grub. These result in a new function in grub.cfg: 
function load_video {

This is empty by default on Wubi installs. Actually it's empty on my normal Maverick install too. But the same fix on 10.10 for Wubi fixes boot problems on Maverick - regardless of the empty function.
PS you don't have to fix 10.10 unless you upgraded to 10.10 from 10.04.1 or - if you want to break it - just reinstall the same version of grub-pc.  But almost guaranteed the next update to grub-pc on Maverick will break it unless a fix for Wubi is provided beforehand.

11.04  Natty Alpha
On Natty, the grub.cfg is syntax checked by 'update-grub' (actually grub-mkconfig) before the update is completed. It finds and rejects this empty load_video function, and results in the grub.cfg NOT being generated at all. All you get is
This affects a brand new Natty Wubi install, so there is no grub.cfg at all. Applying the same fix as for 10.04.1 does not work, as update-grub never completes. You can rename to grub.cfg and it boots, but this is a manual step, so not a fix. In any case, it seems that Natty Wubi will boot with the full complement of Grub modules in /boot/grub. It spits out a bunch of errors, but completes. When these errors cause reboots and when they are harmless is unclear but I guess it has to do with the WUBILDR file.

In any case, Natty is early Alpha, so we should expect weirdness. But if you find yourself confused, you're not alone.

On supported releases 10.04.1 and 10.10, Wubi installs fail after updating package grub-pc. The current community-provided workaround fix does not work on Natty - this is only significant because fixes are usually applied to development releases before supported releases, and to get the fix into 10.04.1 we probably need a fix that will work on all.

No comments:

Post a Comment