Virtualbox Resize Disk VMDK to VDI

I have a virtual machine Windows XP guest with a VMDK drive. One day it said the C drive was full. In Virtualbox resize disk VMDK to VDI.

As seen here.

Virtualbox Resize Disk and convert VMDK to VDI

Backup your data from the 2nd partition

It is possible that you have an extended partition on your VM. You need to back up this data first.

Run the VM as normal. Go to that partition and backup that data.

Turn off the VM and then run these:

VBoxManage clonehd "source.vmdk" "cloned.vdi" --format vdi

Resize to 50GB

VBoxManage modifyhd "cloned.vdi" --resize 51200

Now download gparted from here.

Modify the settings of the VM. Go to the VM settings then Storage.

Under Controller: IDE

Right click on the “source.vmdk” file and and select “Remove attachment”.

Right click on the “Controller: IDE” and select “Add hard disk”. Locate the “cloned.vdi”.

In attributes set the hard disk to “IDE Primary Master”.

vb-storage-hard-disk

Add the gparted iso as an Optical Drive. Select the “IDE Primary Slave” and check the “Live CD”.

vb-storage-gparted-iso

Start the VM and hit F12 or the key to boot devices

vm-gparted1

Select the CD ROM.

Now the gparted menu will come up.

vm-gparted2

  • Don’t touch the keymap
  • Which language do you prefer? (leave the default): hit enter
  • Which mode do you prefer? (default 0): hit enter

As seen here. It says to remove the extended partition /dev/sda2.

I read here. To get rid of the swap partition. Which prevents you from expanding the root partition.

This made sense since I had to backup the data from the extended partition and remove it.

After deleting the extended partition.

Right click on the current partition and “Resize”.

vm-gparted3

Move the arrow all the way to the right.

vm-gparted4

vm-gparted5

vm-gparted6

Apply the changes.

vm-gparted7

vm-gparted8

Restart the VM and it should have the disk resized.

vm-gparted9

When you restart the VM and go to settings you will see that the gparted iso has been ejected.

vm-gparted10

When you restart the VM. If it is a Windows guest it might ask you to check the consistency of the drive.

vm-gparted11

Here is proof that the Windows guest C drive was extended from 10GB to 50GB

vm-gparted12

Troubleshooting

Gparted doesn’t work

When I ran gparted the first time. It wouldn’t do anything. I hit enter on the 1st option and would go back to the same menu.

What I realized is that the gparted iso file was not complete. The file should be around 269MB. When I downloaded the file it said 10MB.

The VM doesn’t run

When I tried to run the VM to backup the data it would give the blue screen of death.

I previously tried to change the settings on the VM so it would look like this.

With the hard disk as a SATA controller. It just wouldn’t run.

I changed the settings back to what I had before. Having the hard disk as an IDE controller. Then it ran normally.

Leave a Reply