How To Increase Virtualbox Disk Size For Dynamically Allocated Disks

In this tutorial, I’m going to show you how to increase Virtualbox disk size for dynamically allocated storage. This method will only work if your virtual disk is in .vdi or vhd format. I also assume that your host OS is Linux. If you want to know how to increase the size of a fixed size disk, then read the next article.

Find Out If Your Virtual Disk is Dinamically Allocated

Open you virtual machine settings and click Storage on the left pane. Select your virtual disk under Storage Tree. You can see the information about your virtual disk on the right. You can see that my virtual disk is dynamically allocated.

dynamically allocated storage

BackUp Your Virtual Hard Disk

Before we increase the size of our virtual hard disk, it’s always a good idea to make a backup of it in case something go wrong.

First, right click on the location line and copy the location of your virtual hard disk.

virtual disk location

Then click the minus icon to remove the virtual disk from virtual machine.

detach virtual disk from guest

Next open up a terminal on your host OS and run the following command to backup the virtual hard disk.

cp /location-of-virtual-disk /location-of-backup-of-virtual-disk

Repalce the location with the real location of your virtual disk. For example, I executed this command:

cp "/home/matrix/VirtualBox VMs/ubuntu/ubuntu.vdi" "/home/matrix/VirtualBox VMs/ubuntu/ubuntu-backup.vdi"

Note that because the location of my virtual disk contains space, so I added double quotes around the location. Make sure your backup disk name is different from the origial disk name.

Increase Virtualbox Disk Size For Dynamically Allocated Disks

Now you can use the vboxmanage comand to enlarge your virtual disk. The syntax is as follows:

vboxmanage modifyhd /location-of-your-virtual-disk --resize size-in-MB

Specify the new size in Megabytes.  For instance, I entered the following command to increase my virtual disk to 10GB.

vboxmanage modifyhd "/home/matrix/VirtualBox VMs/ubuntu/ubuntu.vdi" --resize 10240

You can’t make your virtual disk smaller using this command.

Now open your virtualbox settings to attach the virtual disk back to your virtual machine. Click the plus icon, and select Add Hard Disk.

add hard disk to vm

Choose your enlarged virtual disk. Once your added your virtual disk back, you can check out the new size of it. You can see that my virtual disk is now 10GB in size.

increae virtualbox disk size

Use Gparted to Expand the File System of Your Guest OS

Although your virtual disk size is increased, your guest OS can’t use all of them right now. So you need to boot your virtual machine from a Live CD/DVD that contains Gparted to enlarge the file system of your guest OS.

To boot your virtual machine from a Live CD/DVD, follow these steps.

Open you virtual machine settings and click Storage on the left pane. Under storage tree, click Controller: IDE then click the optical drive icon to add a Live CD/DVD image file. I use the ubuntu live ISO file because it contains Gparted.

add optical drive

Now click System on the left pane, in Boot Order, make sure Optical is first on the list. Save your settings and start your virtual machine.

virtualbox boot order

Now you are in a Live OS. Open Gparted program.

increase virtualbox disk size

As you can see there’re 2GB of unallocated space. To use this unallocated space, first disable swap partition. Right click on the linux-swap partition and select swapoff.

swapoff

Then right click on linux-swap partion and select delete. Next right click on the extended partition and select delete. Apply your changes.

Now you can enlarge your root file system. After you enlarged your root file system, shut down your virtual machine and boot it for virtual disk. You should be able to use the extra spaced added.

Rate this tutorial
[Total: 54 Average: 4]

5 Responses to “How To Increase Virtualbox Disk Size For Dynamically Allocated Disks

  • Francesco
    5 months ago

    thanks it worked

  • Anco van Bergeijk
    5 months ago

    Great this helped me a lot. Ubuntu host with 32gb Win10 guest. Now increased to 50gb. Good info

  • Jer Bear
    5 months ago

    Best not to hit that minus key until you have successfully copied the vdi, not just it’s location.

  • Glabra Cyathea
    5 months ago

    Thanks for the great howto, I just got a problem with the guest OS refusing to see the increased size.

    In attributes it shows the correct virtual size (I increased the size for the guest OS, a Win7, to 40000 MB aka 39,06 GB) but neither the Win7 nor the gparted that I booted from iso sees more than the former size of 29 GB.
    Is there anything else I can do about that?

  • If you are using a newer version of VirtualBox (I have 5.2.12 ) , you can resize the dsk in the VBox manager app under
    File->VirtualMediaManager. Select the disk, and move the slider to the new size.

    Don’t forget to reattach the .vdi to your VM after resizing.

    I attached the gparted-live-0.31.0-1-amd64.iso to my VM, and booted from it.

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.