Web Dev, Linux, WordPress & More

Posts tagged ‘VDI’

Compact a VirtualBox Windows Guest on Ubuntu Linux

by eric on November 11th, 2008 in: Linux

I use VirtualBox to run Windows XP as a virtual machine within Ubuntu Linux and periodically like to compact the virtual drive (VDI) file.

Being a bit boneheaded, every time I do this, I spend ten minutes searching for instructions, so I thought I’d post them here both for myself, and for anyone else it may help.

Steps to Compact a VirtualBox WinXP Guest in Linux

  1. While in your Windows XP virtual machine, download the sdelete program and save it to your c: drive in Windows.  This program allows you to ‘zero out’ the free space on the drive by writing zeros to the unused sectors.
  2. In WinXP go to Start/Run and type ‘cmd‘ to open a command prompt.
  3. Change directory (cd) to the location where you saved the sdelete.exe file.
  4. Enter ‘sdelete -c c:/’ to execute the program.
  5. Once sdelete is finished, shut down the Windows virtual machine.
  6. Open a terminal in Linux and cd to the directory that contains the VDI you’d like to compact.
  7. Type ‘VBoxManage modifyvdi xxxxx.vdi’ compact where xxxxx.vdi represents the filename of the virtual disk you’d like to compact.
  8. After the command is runs, your VDI will be reduced in size.

There’s a ton of information on Sun’s VirtualBox site and forum.  Here’s a forum thread that I found especially helpful.