Discussion of this wiki can be found here

Resize and duplicate the Wubi virtual Disk

This document describes how to resize a Wubi virtual disk. There are two distinct techniques.

The first, described here, is not strictly a resize, but rather a duplication to a new virtual disk. This has the benefit in that it doesn't modify your current root.disk, and also leaves a backup. On the downside, if you want to go from a 7GB Wubi install to a 10GB Wubi install, you need a full 10GB of free space, as well as enough free space for Windows to operate (so may not be ideal if you are low on space). This technique must be run from within the booted Wubi install.

The second technique is a true resize, which must be performed from a live CD. This is much faster and can make better use of the available space. See here for details.

Automated resize

First download the attached file wubi-resize-1.7.tar.gz to your Downloads directory, right-click and choose "Extract here". The rest of the resize is run from the Terminal.

For usage instructions:

cd ~/Downloads/wubi-resize-1.7
bash wubi-resize.sh --help


To create a new 10GB virtual disk:

sudo bash wubi-resize.sh 10


The following screenshot (from release 1.6) shows what the resize looks like: wubiresize.png

After the script is completed it will instruct you to reboot into windows, rename the file \ubuntu\disks\root.disk to \ubuntu\disks\OLDroot.disk and then rename the file \ubuntu\disks\new.disk to \ubuntu\disks\root.disk

Do not delete the OLDroot.disk until you have confirmed the new root.disk is working (or keep OLDroot.disk as a backup).

Note: the script will merge separate virtual disks into a single virtual disk and automatically adjust /etc/fstab accordingly. If this is not desired, use the manual method. The script limits the size of the new virtual disk to 32GB. Please refer to the usage instructions for options if you require a larger size (although I would recommend migrating to a normal install if this is the case).

How long does it take?:

To create a 5GB disk from a freshly installed Ubuntu on my machine, "dd" takes 4 minutes, "mkfs" takes 9 seconds, and "rsync" takes 6 minutes. On larger installs you can expect it to be longer, depending on the size of the new disk, and the amount of data - a rough guideline would be 20 to 30 minutes.

What's new in version 1.7

Supported ACL (access control lists) used for mounting removable media.

What's new in version 1.6

Added support for grub-legacy (original install on Ubuntu 9.04 or earlier), as well as some minor formatting changes and clean up.

Added with version 1.5b is the "--resume" option. You can use this if the initial resize failed to complete normally due to an rsync copy error e.g. file corruption. After fixing the corruption rerun with this option. It can also be used to keep an up to date copy of the root.disk (it synchronizes the new.disk with the current install).

Known issues:

None.

NOTE: the root.disk is a single file stored on the /host partition. There is a higher risk storing data within this file and I strongly recommend maintaining regular backups. Also avoid hard shutdowns that can lead to filesystem corruption.

CREDIT... I used the LVPM guide by Gena Kovaks and the scripts by Agostino Russo from the Wubi guide (and lupin package) as reference material.

The code is now hosted on GitHub. You can keep track of new development, contribute or log Issues there. See https://github.com/bcbc/Wubi-resize

Verifying the script

The archive file contains signed sha256 and md5 checksums of the wubi-resize.sh script. You can manually verify this as described here...

Download my GnuPG public key, with the same keyid as on my launchpad page:

gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x3310A652

Verify the checksum files are signed by me:

gpg --verify SHA256SUMS.gpg SHA256SUMS
gpg --verify MD5SUMS.gpg MD5SUMS

Verify the script file:

sha256sum --check SHA256SUMS
md5sum --check MD5SUMS

If any of the above fail, do not use the script. Note that it's normal for my key to appear untrusted, as long as the keyid is correct and the checksum file signatures are valid. I've also included a script verify.sh that will perform the above steps.

Manual resize

For those interested, I've included the commands to perform the resize manually.
WARNING... the commands "dd" and "mkfs" are very dangerous if used incorrectly (they can destroy all the data on your computer). It is recommended to use the automated resize (the attached script) as there are additional checks and safeguards against errors.

Please ensure you have enough space for the new virtual disk before proceeding. E.g. for a 10GB disk you'll need 10GB free as well as enough space for Windows to operate. Do not use this if your /host is a FAT32 partition.

  1. Unmount any partitions that are not mounted under /host or /media. (e.g. sudo umount /windows )
  2. Run all commands as root; check free space on /host

$ sudo -i
# df -h /host

3. Create a new virtual disk of e.g. 10GB (10,000 MB) - change count= parameter as appropriate.

# cd /host/ubuntu/disks
# dd if=/dev/zero of=new.disk bs=1MB count=10000

4. Format the disk with the ext4 file system

# mkfs.ext4 -F new.disk

5. Mount and copy files to new virtual disk

# mkdir -p /media/newdisk
# mount -o loop new.disk /media/newdisk
# rsync -aAXv --exclude '/sys/*' --exclude '/proc/*' --exclude '/host/*' --exclude '/mnt/*' --exclude '/media/*/*' --exclude '/tmp/*' --exclude '/home/*/.gvfs' --exclude '/home/*/.cache/gvfs' --exclude '/root/.gvfs' --exclude '/var/lib/lightdm/.gvfs' / /media/newdisk
# umount /media/newdisk
# exit

6. You're done! Reboot into windows, rename the file \ubuntu\disks\root.disk to \ubuntu\disks\OLDroot.disk and rename the file \ubuntu\disks\new.disk to \ubuntu\disks\root.disk. Then reboot back into Ubuntu -- only delete the OLDroot.disk if you are sure it worked.

Note: if you have previously created separate virtual disks e.g. for /home, this process will merge /home back into the new virtual disk. That means you need to remove the separate entry for /home from your /media/newdisk/etc/fstab (before the umount command) (or change the rsync command to --exclude '/home/*' altogether).

If you are ready to resize you might also consider migrating the Wubi install to a normal dual-boot (to partition)

ResizeandDuplicateWubiDisk (last edited 2013-03-08 06:09:46 by bcbc)