Wednesday, April 18, 2012

Increasing VDI size on a Virtualbox VM

Update: Since v4, there is a command line to perform the following. Please refer here

You cannot actually increase the size of a VirtualBox VM VDI. What you can do instead is to copy the VDI to a new VDI with a bigger size

The steps are as follows

1. Create and add new VDI to the VM
2. Copy content of existing VDI to new VDI
3. Set the new VDI boot partition as active

To create a new VDI

1. Power off the VM
2. Open the VM Storage settings 
3. Select the controller where the current VDI is attached to
4. Click on 'Add attachment' 
5. Choose 'Add hard disk' 
6. Choose 'Create new disk'
7. Follow the wizard and specify the size you desire

To copy content of existing VDI to the new VDI

1. Choose Ubuntu iso as the virtual CD/DVD disk file for the VM. (Download Ubuntu iso if you have not already done so)
2. Start the VM and boot to Ubuntu 
3. Select 'Try'
4. Once the live Ubuntu is up, run Gparted
5. Select the existing VDI, right click and choose copy.
6. Select the new VDI, right click and choose paste.
7. Apply the changes.
8. Once successfully applied, reboot the VM

To set the new VDI boot partition as active

1. Boot the VM using the existing VDI as per normal
2. Run command prompt and type the following

diskpart
list disk
select disk n  
list partition
select partition n
active

Note: 'n' is the new VDI disk and partition number

3. Power off the VM
4. Remove the old VDI from the VM
5. Start the VM

Note: If you still unable to boot the VM with the new VDI with MBR error, you can do the following

1. Choose Windows XP iso as the VM virtual CD/DVD disk file. 
2. Start the VM and boot to Windows XP installation disk
3. Select 'Recovery Console'
4. Select the correct Windows directory
5. Run command 'fixmbr'
6. Reboot the VM.

No comments: