VirtualBox does not offer anything for this task -- you need to do it yourself. It's not that hard:
Get more disk space
- Add an extra virtual hard disk to the machine with the disk size you want to achieve.
- Get a Linux live CD (like the Ubuntu live image) that offers
fdisk
,dd
andgParted
. - Boot the guest from the CD, open a terminal (on the guest, not the host!) and become root:
sudo su
-
fdisk -l
to see the disk information. \
There should be one drive with some partitions and one without any. The first is the source (e.g./dev/sda
), the latter your target for cloning (e.g./dev/sdb
). - Clone the drive content with dd:
dd if=/dev/sda of=/dev/sdb bs=1024000
This will copy any content from your source to the target. Be careful to not use the wrong device names, dd does not ask for confirmation! Thebs
parameter sets the block size and may increase transfer speed. If you are curious aboutdd
's progress, check the corresponding note.
Expand partition
Now your virtual drive has more space but the partition is still of the same size. You probably also want to enlarge it as well (these step are especially useful for Windows guests as they cannot resize their system partition themselves):
- Shutdown the virtual machine, disconnect the old drive, boot the live CD again. If you do not restart after cloning, gParted will be confused by the disk layout.
- Start gParted (on Ubuntu: System → Administration) and resize the partition on the target drive to its full size.
- Shutdown the VM, remove the live CD and boot up your guest system.
This should be it. Windows will notice the drive change and run CHKDSK on its next boot but should come up fine afterwards.
As always: Have a backup of important data before doing such things.
Posted by Arne Hartherz to makandra dev (2011-07-15 12:57)