Monday, March 1, 2010

VirtualBox: Shrink guest volume

Today, I tried to increase space on my working notebook. I usually work in virtual environment and in the last period I’ve found very cool VirtualBox virtualization product.

From a first analysis, I found that the logical space occupied by guest disk was less than the physical space on my hard disk (32 GB versus 37 GB). Unfortunately VirtualBox UI don’t provide any tools to shrink volume such as in MS Virtual PC. So, I had a short search on Google and I found out a couple of very interesting posts to  accomplish the task.

Here, summarized the steps:

  1. Defrag your guest disk using windows defrag,
  2. Download the following tool (SDelete) and copy and extract it in your virtual environment,
  3. Open a console in guest system, go to SDelete directory and type the following command:

    sdelete -c c:\

    where C:\ is the volume to shrink.
  4. Shutdown the virtual machine.
  5. In the host environment open a console, go to VirtualBox directory (in my case was: “C:\Program Files\Sun\VirtualBox”)
  6. Type the following command:

    VBoxManage.exe modifyvdi <your path to vdi file>\file.vdi compact

The last operation is the slowest and requires about 20 minutes (probably depends on machine and file size).


VirtualBox version: 3.1.4

Host O.S.: Windows 7 x64

Guest O.S.: Windows 2008 x86


kick it on
Save to delicious 0 saves