Migrate a Wubi install manually
This page details the steps required to manually migrate a Wubi install to a normal dual boot.
To migrate your Wubi install automatically, please refer instead to: https://help.ubuntu.com/community/MigrateWubi
It is not recommended to use these instructions to manually migrate your Wubi install. They are more for documentation of the process involved, or those with an interest in doing it manually. The automatic migration referred to above is much safer as it does a lot of validation that is not included here.
If you still choose to follow these instructions make sure you understand each command before running. The mkfs.ext4 command will format the partition you specify without prompting for confirmation.
These instructions only work on Wubi installs from release 9.10 and later (that use Grub2, not Grub-legacy). The code examples shown assume that the install will be migrated to partition /dev/sda5 and that there will be a swap on /dev/sda6. If there is no swap, just ignore lines containing /dev/sda6. If there is a swap partition it must be of type 'swap'. Change the device names as appropriate.
Most of these commands are best cut-and-pasted to avoid typos. If you need to change the device names, I recommend doing it in a text editor before pasting to terminal. Otherwise, if you paste a linefeed by accident the command will run before you have a chance to change it.
1. Do this all as root
$ sudo -i
1.a. Ensure you do not have grub-legacy. If the output of the following shows version 0.97 then please do not continue. These instructions only work with grub versions 1.96 and greater.
# grub-install --version
2. Format new partition if not done so already - make sure it's empty, large enough and unmounted
WARNING -- the next command will wipe all existing data on /dev/sda5
# mkfs.ext4 /dev/sda5
3. Mount new partition and copy files.
# mkdir /tmp/wubimove # mount /dev/sda5 /tmp/wubimove # rsync -av --exclude=/host --exclude=/mnt/* --exclude=/home/*/.gvfs --exclude=/home/*/.cache/gvfs --exclude=/media/*/* --exclude=/tmp/* --exclude=/proc/* --exclude=/sys/* --exclude=/var/lib/lightdm/.gvfs / /tmp/wubimove # chmod -x /tmp/wubimove/etc/grub.d/10_lupin
4. Setup swap partition and enable hibernation (swap must be at least as big as RAM to hibernate)
# mkswap /dev/sda6 # echo "RESUME=UUID=$(blkid -o value -s UUID /dev/sda6)" > /tmp/wubimove/etc/initramfs-tools/conf.d/resume
5. Edit fstab (blank out wubi mounts with sed and add new partitions)
# sed -i 's:/.*[\.]disk .*::' /tmp/wubimove/etc/fstab # echo "UUID=$(blkid -o value -s UUID /dev/sda5) / ext4 errors=remount-ro 0 1" >> /tmp/wubimove/etc/fstab # echo "UUID=$(blkid -o value -s UUID /dev/sda6) none swap sw 0 0" >> /tmp/wubimove/etc/fstab
6. Remove lupin support and update grub (all in chroot). Note that this step installs the grub bootloader to /dev/sda and will replace your windows bootloader (the line 'grub-install /dev/sda') -- see note below
# mkdir /tmp/wubimove/host # for i in dev proc sys dev/pts host; do mount --bind /$i /tmp/wubimove/$i; done # chroot /tmp/wubimove # dpkg-divert --local --rename --add /sbin/initctl # ln -s /bin/true /sbin/initctl # apt-get -y remove lupin-support # update-grub # grub-install /dev/sda # echo SET grub-pc/install_devices /dev/sda | debconf-communicate # rm /sbin/initctl # dpkg-divert --local --rename --remove /sbin/initctl # exit # for i in host dev/pts dev proc sys; do umount /tmp/wubimove/$i; done # rmdir /tmp/wubimove/host # umount /dev/sda5
7. Update wubi grub menu to pick up new install and exit sudo
# update-grub # exit
You're done. When you reboot, you should see a grub menu instead of the windows boot menu. Select the first entry. If you didn't run 'grub-install' you can boot from the wubi menu, select your new install from the bottom after the Windows entry.
NOTE on installing the grub bootloader: you can try out the new installation by booting it from the wubi grub menu first - if you want to make sure everything is working before replacing the windows bootloader. To do this, bypass the line 'grub-install /dev/sda' and the following line (in step 6.). You can then install the grub2 bootloader manually later after booting into the new install. I also recommend updating the grub menu after booting into the target partition
$ sudo update-grub
- Mounted partitions under /host and /media are excluded from the rsync copy automatically. Partitions mounted under other mountpoints are not and will be copied unless manually unmounted first (when running manual migration).
Only the current kernel's initrd.img is updated on the migrated install; if you require others you can update them with "sudo update-initramfs -u -k <kernel version>".