Friday, November 18, 2011

How to Resize a VirtualBox VM in Windows

Have you ever had a VirtualBox .vdi in Windows and wondered how you could make it larger? We all have to do this at some point, so here's what you need to know:

1) Shut down the virtual machine that uses the specific .vdi
2) Fire open a command prompt and add the virtual box bin path to your path. In my case this was done by executing:

set PATH=%PATH%;C:\Program Files\Oracle\VirtualBox

3) Change directory into the folder that contains the vdi file of interest, say 'disk.vdi'.
4) Run vboxmanage modifyhd with the resize parameter to resize the disk. If you're interested in increasing the disk to 150Gb, this is what you would do:

vboxmanage modifyhd disk.vdi --resize 150000

5) Fire open the Windows virtual machine.
6) Within the virtual machine, fire open a command prompt.
7) Execute diskpart

This will leave you at a DISKPART> prompt

8) Execute 'list volume' to obtain a list of volumes.

Note which volume number you are interested in modifying. Suppose this number is 2.

9) Execute 'select volume 2'
10) Execute 'list disk'

Note which disk number you are interested in modifying. Suppose this number is 0.

11) Execute 'extend size=150000 disk=0'
12) Execute 'extend filesystem'


Now if you open up a Windows Explorer window and right click on your disk, you should have 150Gb available.