Growing your Virtual Disks

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.

- FB 

Comments:

Hmm, suggestion #3 is very smart indeed.

Posted by Achim on August 14, 2009 at 05:33 AM BST #

I shut down my VM and edited the properties. I increased the max size of for the dynamically growing disk..but what will actually make it grow to use that size? I restated the VM and tried my install operation again but the app still sees the local drive with less than 1 gig of space instead of 10gig.

Posted by Craig on May 26, 2010 at 11:18 AM BST #

sorry, I got it. I need to keep thinking of the VM HD settings as the physical disk. I just went into Disk Management within Windows 2008 R2 server and the max space I added shows as unused space...so I increaded the C partition to use that space and all is well. No reboot even needed.

Posted by Craig on May 26, 2010 at 12:26 PM BST #

@Craig: where do you change the max size of a dynamically growing disk? I don't see a size for the harddisk in the .xml file for the vm, just a uuid. Is that only possible for one created by VirtualBox, or also for an existing .vmdk added to the media manager?

Posted by Herb on November 15, 2010 at 02:07 PM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Fat Bloke

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today