Changing VirtualBox’s Disk Image Sizes

I was running out of room in my Virtual Box Windows 7 disk.  Windows was reporting used space of 18.6 GB and free space of 1.22 GB.  My Mac was reporting that my disk image was using up 21.39 GB.


On your Windows Guest:

  1. Run Disk Cleanup.
  2. Run Disk Defragmenter.
  3. Download SDelete and use it to zero out free space. I put sdelete in C:\Windows\System32 and then ran it like this from the command prompt.
    C:\> sdelete -c c:/

  4. Shutdown Windows.

On your Mac Host:

  1. Run VBoxManage from the Terminal to compact the disk image.
    $ VBoxManage modifyhd Windows.vdi --compact

Sad Story

I first tried shrinking the disk image to see if that would free up room using the instructions above which were based on the article How To Shrink Your Virtualbox VM And Free Up Space For Your Hard Disk.

After doing this Windows reported used space of 18.8 GB and free space of 1.03 GB.  In other words no difference. Sad smile  But on the Mac the disk image was now only using up 20.51 GB.


On your Windows Guest:

  1. Shutdown Windows.

On your Mac Host:

  1. Run VBoxManage from the Terminal to resize the disk image. This is how I did it.
    $ VBoxManage modifyhd Windows.vdi --resize N

On your Windows Guest:

  1. Restart Windows.
  2. Use diskpart to resize the C: drive to use the new space.

Happy Story

Realizing that compacting did not work I shut down again and this time increased the size of the disk image by 10 GB from 20 GB to 30 GB (N = 30720).

VirtualBox showed in its settings that the disk image size was now 30 GB.  But Windows still reported used space of 18.8 GB and free space of 1.03 GB.  Again no difference. Sad smile  And on the Mac the disk image was still the same but that was to be expected.

Back to Google which led me to Windows’ brilliant tool diskpart.


Microsoft DiskPart version 6.1.7600
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: WIN-7-IMAC-POOP

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     D   VBOXADDITIO  CDFS   CD-ROM        38 MB  Healthy
  Volume 1         System Rese  NTFS   Partition    100 MB  Healthy    System
  Volume 2     C                NTFS   Partition     19 GB  Healthy    Boot

DISKPART> select volume 2

Volume 2 is the selected volume.

DISKPART> extend size=10240

DiskPart successfully extended the volume.

Windows now reported free space of 11.0 GB.Open-mouthed smile

End Note

I originally tried resizing the disk by specifying the size of how much I wanted the disk increased, i.e. 10 GB or N=10240.

$ VBoxManage modifyhd Library/VirtualBox/HardDisks/Windows\ 7.vdi --resize 10240

This failed with the strange error:

Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!

Fortunately I found out in one of the VirtualBox forums that this happened because I gave the wrong argument to resize.  Too bad the error message wasn’t a little more helpful. Smile

VirtualBox Unable to Run Two Instances

Double Bows by Nicholas_T

I have been using VirtualBox for awhile and have been pretty pleased with it considering it’s a free solution.  I blogged about wanting to try it over two years ago.

Today I started up Windows 7 on my iMac.  Then I tried to start up Windows XP but got this error.

Failed to open a session for the virtual machine Windows XP Pro Media Center.

PIIX3 cannot attach drive to the Secondary Master

Unknown error creating VM (VERR_SHARING_VIOLATION).

Fortunately Google came to the rescue and led me to this article in the VirtualBox forums, Can’t run multiple Instances on OSX Leapord.  Once I unmounted the DVD drive in Windows 7 (Devices –> CD/DVD Devices) I was able to start Windows XP.

The lesson is you can’t run two instances if both want to mount the same DVD drive. Not sure if this is a problem with Parallels or VMWare.