Resizing VirtualBox Disks – I wanted to resize the hard drive of my VM, and I figured that this would be an easy task. As it turns out, it is extremely easy. The only problem was that it wasn’t working. Here is how I resolved that error. Please note, this is my dev VM. If I mess things up, I’ll wipe it and start over. If you can’t be so cavalier about what you do on your VM’s, you better make a backup first.
Resizing VirtualBox Disks
I ran the standard modifyhd command from the command prompt. To do this, change the directory to your VirtualBox installation and run VBoxManage in this format:
VBoxManage modifyhd [path to vdi file] [dash dash]resize [size]
So the command was:
VBoxManage modifyhd D:VM’sDevABC.vdi –resize 100000
This is resizing the disk to 100Gb. Note that there is a double dash before the word resize. Also, if your path has any spaces, enclose the path in quotes. For example:
VBoxManage modifyhd “D:My VM’sDev VMABC.vdi” –resize 100000
When I then go to my VM’s settings and have a look at the Virtual Size, I can see that is has been resized. So far so good.
I then start my VM and go to Disk Management. Looking at the disk I can see that…. nothing changed.
Resizing VirtualBox Disks Fails Due To Snapshots
The reason that the resize didn’t work was because I had a snapshot of my VM (as this article suggests). If you’re using fixed disks, you’re out of luck too by the way. The only reliable way I found to resolve this issue was to get rid of my snapshot.
There is probably a better way to do this, but this is what worked for me. Power off the VM, right-click the VM and select the Clone menu item from the context menu.
Give your VM a new name. I wanted to create a dev specific VM anyway.
Select to create a full clone. I didn’t want to create a linked clone in this instance.
Because I wanted to get rid of the snapshots, I only selected the current machine state.
Cloning the machine takes some time, depending on the size of the VM being cloned. Now would be a good time to grab a cup of coffee or catch up on the latest hacker news.
When the cloning process is complete, have a look at the disk size. You need to start the resize process from the beginning.
Opening the command prompt, run the modifyhd command. Note that I have had to use quotes around the path because it contains a space.
After this process completes, start your VM and head on over to Disk Management. You will now see that there is unallocated space available on your primary drive.
Right-click the partition and select to Extend the volume. Complete the wizard that follows.
After the wizard completes, you will have a resized disk.
There is probably an easier way to do this, but after everything I tried, this was the most direct route to resolve the problem at hand.