2013年10月30日星期三

Resize VirtualBox disk size

Suppose we are using Windows as the Host

Step 1) List hard disk drive
Open the command prompt and enter:
cd "C:\Program Files\Oracle\VirtualBox\"
vboxmanage list hdds

you will see something like this:
UUID: 5ebf0266-4e9e-4b7e-b9f6-6d67514919c3
Parent UUID: base
Format: VDI
Location: /VBOX/Windows XP/Windows XP.vdi
State: inaccessible
Type: normal
Usage: Windows XP (x86) (UUID: c90339ab-edb1-4b30-890b-ea7153b6cf4b)

Step 2) Determine the file is ended with VDI or VMDK extension.
If it is VDI, goto step 3a.
If it is VMDK, goto step 3b.

Step 3a) Resize the disk using UUID <- Recommended

Using the above as an example:
50000 = 50GB

VBoxManage modifyhd 5ebf0266-4e9e-4b7e-b9f6-6d67514919c3 --resize 50000

Step 3b) Resize the disk size by selecting UUID <- Recommended

Using the above as an example:
50000 = 50GB

VBoxManage clonehd 5ebf0266-4e9e-4b7e-b9f6-6d67514919c3 "c:\temp\clone.vdi" --format VDI
VBoxManage modifyhd "c:\temp\clone.vdi" --resize 50000
VBoxManage clonehd "c:\temp\clone.vdi" "NEW_HARK_DISK_DEST" --format VMDK

Attach the re-sized disk in VirtualBox.


Step 4)
Use GParted to expand the partition.

After verify the disk is working properly,
the original disk and also the "c:\temp\clone.vdi" one can be deleted safely.