By Fat Bloke on Aug 14, 2009
When I create new Virtual Machines, or guests, in VirtualBox I tend to skimp a little on the size of the virtual hard disk I create because I'm trying to save on host disk space. And this tends to come back and bite me when the guest quickly fills the disk and I run out of disk space in the guest. So you think, "wait a minute, this hard disk is just a file, so why can't I make the file bigger?".
The problem here is that, yes, to the host system it is just a file, but to the guest it is a hard disk and they're not expected to suddenly grow. So if or when they do, you need to tell the guest OS about this, by modifying the partition table too.
So here are a few options that you can use to deal with lack of disk space in the guest:
1. Compact the disk
One option is to not grow the disk at all but reorganize the data on it. Achim told us "How to Compact your Virtual Disks" last month. Note that you don't need to mess around with disk partitions with this option.
2. Create a new bigger disk
You could simply create a new bigger disk and copy over the old data but you still need to tell the guest that the new hard disk has bigger partitions. Here's a step by step guide to doing this.
3. Create a bigger disk to start with but with a smaller root partition
One of the VirtualBox team (thanks Frank!) gave me this tip to creating large virtual disks while controlling host disk space at the same time.
"Instead of creating a dynamically growing disk image with, for instance 20GB, the user should create a large disk image, say, 100GB, but he should only partition the first 20GB by the guest. (ed - you typically get the chance to do this during OS install). Doing so, the disk image will never occupy more than 20GB (plus some maintenance information) as long as the guest doesn't need more. Once the guest is short in disk space, simply increase the guest partition using some common tool, for instance boot the guest with a Ubuntu Jaunty LiveCD and use the Partition Manager to increase the guest partition to your needs (that application can handle NTFS partitions as well). "
4. Using a networked storage server.
If you are using VirtualBox's built-in iSCSI support to a networked storage server such as Sun's Storage 7000 systems, or maybe simply a Solaris server running as an iSCSI target with ZFS, then you can resize the disk easily using:
# zfs set volsize=10G poolname/volname
But you still need to repartition this disk, as you need to do in 2 and 3 above too.
Hope one of these works for you.