Ubuntu – Fixing grub menu after migrating wubi to partition

dual-bootgrub2migrationwubi

I installed Ubuntu 12.04 via Wubi a couple of weeks ago, and today used the script on https://help.ubuntu.com/community/MigrateWubi to move it to a new partition. Now I'm having a bit of confusion about how to clean up the original Wubi install.

Here's the setup: two hard drives, /dev/sda contains my Windows 7 install, and /dev/sdb is a secondary drive with a large partition for data. I had Wubi installed on /dev/sdb1, and have now created two new partitions sdb2 and sdb3 for the installation and swap respectively.

On booting, the computer starts the Windows boot manager with two options, Windows and Ubuntu (this is the behaviour I want, as I use Windows the majority of the time and don't want to accidentally boot to Ubuntu while Windows is hibernated); but now the grub loader on choosing the Ubuntu option has suddenly become rather crowded. It seems that Wubi has been left intact at the top of the list, with the migrated version (on /dev/sdb2) pushed lower down on the list.

This has left me with two questions:

  1. How do I remove the Wubi installation from the grub list?
  2. Is it safe now to uninstall Wubi from within Windows while still allowing its boot manager to direct to Grub on the second drive?

Cheers.

EDIT: I've tried using the Ubuntu-Tweak program as advised below, and it raised rather an interesting question. There were a couple of old kernel versions which were also being shown in the grub list, and that I'd removed. Trying to run any of those gives an error along the lines of "You need to load the kernel first". sudo update-grub didn't take them off the list, and in fact according to the status output it should have also added Windows to grub (which it hadn't). Rebooted into Windows and ran bcdedit, and it looks like it's using Wubi's version of grub with the new version added (hence why update-grub isn't helping at all). This is the relevant section from the bcdedit output:

Real-mode Boot Sector
---------------------
identifier              {816916df-c233-11e0-a9e6-883a7e390b89}
device                  partition=G:
path                    \ubuntu\winboot\wubildr.mbr
description             Ubuntu

where "G:\ubuntu" was the original install folder for Wubi.

When I ran the migration script in the first place it said that it was installing Grub to /dev/sdb – but this on its own isn't a partition. Is there somewhere particular where the migration script could have installed Grub, i.e. somewhere I can point the bootloader so that it will use the correct version of Grub? (After that I'm pretty sure the question about uninstalling Wubi is a moot point)

Best Answer

The Wubi migration will only ever install the Grub bootloader on the drive you are migrating to. In this case /dev/sdb. It does this to make things simpler (and I believe it's the safest option). So the easiest way to boot the migrated install is to set /dev/sdb to boot first in the BIOS options.

The way Wubi boots - and the way you are booting right now - is from the Windows Boot Manager (BCD store), wubildr.mbr (in the \ubuntu\winboot directory), then wubildr (C:\wubildr), then the grub.cfg from inside the Wubi install (the root.disk). This is where you are booting your migrated install from. If you uninstall Wubi ALL these things will be removed (not the Windows Boot Manager but it won't show, because the Wubi entry is deleted).

So you cannot boot the migrated install with the Wubi boot method after getting rid of Wubi. You can instead install grub to the migrated partition and use easyBCD to do it. But personally I wouldn't recommend this. If you have to boot from the drive containing windows (in your case /dev/sda) instead do this:

  1. Boot the migrated install
  2. Install grub to the MBR. Assuming the drive you boot from is /dev/sda you would run: sudo grub-install /dev/sda
  3. Change the boot order so Windows is first.

Code:

sudo mv /etc/grub.d/30_os-prober /etc/grub.d/09_os-prober
sudo update-grub

These last commands just change the order in which Grub generates the menu entries, placing the Windows entry (generated out of 30_os-prober) first.

PS. since you have already tweaked your grub menu on the migrated install, you probably just have to install Grub to /dev/sda to get things to work right and can leave the grub scripts alone.

Related Question