How to extend Windows 7 VM disk size on VirtualBox v4.2.16


The 30GB C: drive was running out of free space on my Windows 7 VM guest on VirtualBox v4.2.16.


1. Shutdown VM.

2. Extend it to 45GB:

[text]$ cd /home/user/.VirtualBox/HardDisks
$ VBoxManage modifyhd windows7.vdi –resize 46080

3. Extend partition size in Windows 7

a. Start the VM

b. Run diskmgmt.msc > right-click C: > Extend Volume...

How to move VirtualBox VM from 1 machine to another

Environment: VirtualBox v4.1.8

  1. Backup everything that you’ll be touching in case anything goes wrong and you need to revert back.
  2. Move the <vm>.vdi hard disk file from the old machine’s "$HOME/.VirtualBox/VDI" to the new machine.
  3. Move the <vm> directory from the old machine’s "$HOME/VirtualBox VMs" to the new machine.
  4. Edit the "$HOME/VirtualBox VMs/<vm>/<vm>.vbox" file to change the old <HardDisk> location to that of the new machine.
  5. Double-click on this vbox file to load it into VirtualBox.
  6. Start the VM. It should load without any error.

How to reduce size of VirtualBox VDI file


VirtualBox version = 4.0.12
Guest OS = Win 7
Host OS = Linux Mint 9 Isadora (based on Ubuntu)

Perform these tasks on all the Win 7 local hard-disks:

  1. chkdsk /F
  2. defrag /X
  3. sdelete -z

Shutdown the Win 7 VM, then run this command on Mint:
[shell]$ VBoxManage modifyhd /home/user/.VirtualBox/HardDisks/win7.vdi –compact[/shell]

That freed up 5GB of space for me, a 20% reduction.