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.
Compacting
On your Windows Guest:
- Run Disk Cleanup.
- Run Disk Defragmenter.
- 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:/
- Shutdown Windows.
On your Mac Host:
- 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. But on the Mac the disk image was now only using up 20.51 GB.
Resizing
On your Windows Guest:
- Shutdown Windows.
On your Mac Host:
- 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:
- Restart Windows.
- 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. 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.
C:\>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.
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.
Thank You. Exactly what i needed. Worked like charm. You saved my Day 🙂
Hi, what was the wrong argument to resize? I tried:
VBoxManage modifyhd myname.vdi –resize 30000
the disksize is 20000, so what is the wrong argument.
Regards,
Marco
Marco, the wrong argument to resize is the amount to increase the disk size. The argument should be the total size, in this case 30720, instead of 10240.
I am not sure why in your case it is not working. That looks right. Maybe the virtualbox.org forums can help.