How to increase the size of a VirtualBox Disk Image
I had created a Windows XP image disk. It is of 5 GB, but I would like to know if there is any simple way to increase the size to 20 GB.
As of VirtualBox 4.0.0, the VBoxManage command line tool offers a simple resize option:
VBoxManage modifyhd /path/to/vdi --resize <mbytes>
After the virtual disk container resize, boot into the VM and resize the partitions to make use of the extra space.
See also: VirtualBox manual, Chapter 8. VBoxManage: modifyhd
There is no simple way to do this that I'm aware of. There's no app that lets you just adjust a number to increase the hard drive size. However, there's a pretty easy tutorial on modhul.com that walks you through a process similar to what others have posted here.
Basically, you:
- create new virtual disk with larger size
- add that drive as a slave to your virtualbox
- boot to gparted Live CD in virtual environment
- use gparted to copy from old hd to new hd
- mark new drive as bootable
One of the commenters on that article state that it took less than 15 minutes to go from 4GB to 10 GB, FWIW.
Here are alternate methods using one of the many live cds available, both commercial and open source, with a disk/machine cloning tool. (clonezilla, ghost, etc.)
Network cloning
Create a new virtual machine with a new empty disk. (20gb per your requirement)
Boot the old virtual machine to the cloning livecd iso image. Set up old virtual machine as source for cloning.
Boot the new virtual machine to the same livecd iso image. Set up new virtual machine as destination for cloning.
Clone system over virtual network. (This takes longer than disk cloning but it is practice for physical network cloning.)
Power off old virtual machine.
Reboot new/cloned virtual machine.
This method can also be used between two physical machines, each running Virtualbox. Or from physical to virtual or vice versa. Or for transferring between Virtualbox and Vmware, Virtualpc, Vmfusion, Xen, Kvm or any virtual client that can boot to a cd or iso image. 5gb is a little heavy but with a good connection even cloning over the internet is possible. I do this for linux clients often but the larger virtual disks I use are only ~700mb (used space), takes less than a hour - setup time included.
or
Disk Cloning
Create a new virtual machine with a new empty disk. (20gb per your requirement)
Add the disk created from the new virtual machine to the old virtual machine to use as the clone destination. Boot old virtual machine to livecd iso image.
Clone system on old virtual machine from the smaller disk to the larger disk.
Power off the old virtual machine. Remove the new/cloned virtual disk from the old virtual machine.
Start the new virtual machine.
These have the advantage of updating the virtual machine to the current version. (The virtual hardware and virtual machine file format may change with VM server updates. This may cause new drivers to be "discovered" in a cloned client from an older version or from a different VM server.) Installing/Updating the VirtualBox client tools should now give you a current virtual machine with a larger drive and you'll still have your original virtual machine unchanged. Just don't run both virtuals at the same time. There may be naming collisions and license issues with windows.
In the case of windows products for virtual clients you may need to re-activate the new virtual. I haven't run into that but I'd heard from others that they had to. I think it has to do with how many things are changed at a time during the clone. (memory, cpu(s), disk, etc.)