Tuesday, May 11, 2010

How To Resize A VirtualBox VM In 3 Easy Steps

VirtualBox does not make resizing a VM easy. Luckily, I’ve collected the 3 necessary steps that you’ll need to resize your VDI files:

Step 1 – Create a New and Bigger VDI file

Use the VirtualBox ‘Virtual Media Manager’ GUI to create a new VDI file that is larger in size.

Step 2 – Use the ‘VBoxManage CloneHD’ Command

This command will copy the original to the New and larger VDI. Open a command window and call this command from the VirtualBox directory. Be sure you properly reference the correct files, for example, here the command I used:

C:\Program Files\Sun\VirtualBox>vboxmanage clonehd --existing e:\virtualbox\ORIGINAL.vdi C:\Users\Mehul\.VirtualBox\HardDisks\NEW_BIGGER.vdi

Sun VirtualBox Command Line Management Interface Version 3.1.8

(C) 2005-2010 Sun Microsystems, Inc. All rights reserved.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Clone hard disk created in format 'VDI'. UUID: 7099c645-15c2-4656-bf90-27a444444444444

Step 2 (optional) – Call ‘setvdiuuid’ in case of an issue

Try to start your VM now that points to the NEW_BIGGER.vdi file. If you get an unusual error like this one:

Cannot register the hard disk ‘PATH’ with UUID {id goes here} because a hard disk ‘PATH2’ with UUID {same id goes here} already exists in the media registry (‘PATH to XML file’).

Then use the following command on your NEW_BIGGER.vdi:

C:\Users\Mehul\.VirtualBox\HardDisks>"c:\Program Files\Sun\VirtualBox\VBoxManage.exe"
internalcommands setvdiuuid MHDXDT1_Laptop.vdi


Sun VirtualBox Command Line Management Interface Version 3.1.8
(C) 2005-2010 Sun Microsystems, Inc. All rights reserved.

UUID changed to: d4c86bf9-3739-4894-9fee-0ec8342432a

Take note that I ran that command from the directory location of the NEW_BIGGER.vdi file. For a good explanation of this command, check out this post.

Step 3 – Resize the local drive in the VM

Your NEW_BIGGER.vdi is larger than before. However, as a final step, you need to increase the local drive in the VM. Windows 7 makes it easy with the disk management.

  • From control panel, bring up ‘Disk Management’.
  • Right click on your local C: drive (Disk 0 usually)
  • Select ‘Extend Volume’

The process is pretty easy to figure out. If you need more info and images then check out this post for a more detail.

And that’s it! You’re done. You now have a bigger drive.

Easy, wasn’t it?

Thanks to this post for majority of the initial guidance.

No comments: