in DevOps

Resizing Vagrant box disk space

Vagrant is a great tool to provision virtual machines! As I’m a passionated Windows user, Vagrant is the weapon of my choice whenever I need to use some Linux-only tools such as Docker. I spinn up a new Linux VM, already configured with the things I need and start working. However, when it comes to resizing a disk, Vagrant is not nice to you…

The problem

Vagrant doesn’t provide any out-of-the-box option to configure or to change the disk size. The disk size of a VM totally depends on the base image used for the VM. There are base images with a 10 GB disk, some with a 20 GB disk and some other with a 40 GB disk. There is no Vagrant option to change this – and even worse: most Vagrant boxes use VMDK disks which cannot be resized!

Resizing (manually) with VirtualBox

As Vagrant doesn’t provide any out-of-the-box functionality, we need to do the resizing “manually”. Of course, we can write a script for this, too, but for now we keep it simple and do it by hand.

  1. First we need to convert the VMDK disk to a VDI disk which can be resized. We do this with the VBoxManage tool which comes with the VirtualBox installation:
  2. Now we can easily resize this VDI disk, e.g. to 50 GB:
  3. The last step we need to do is just to use the new disk instead of the old one. We can do this by cloning the VDI disk back to the original VMDK disk or within a view clicks in VirtualBox:

    2016-01-06 16_32_02-Oracle VM VirtualBox Manager

That’s it! Now start your VM with vagrant up and check the disk space. It’s at 50 GB and we have new free space again!

Best regards,


Write a Comment



  1. Resizing (automatically) with VirtualBox

    This section is missing.
    1. How, through the Vagrantfile, can the VirtualBox image be copied and expanded?
    2. How can the Vagrantfile be modified to install parted and used to expand the partition internally.

    Making a second disk is not acceptable. Vagrant Box should be as lean as possible by default. Vagrant is written in ruby and not Python. 🙁

  2. I have followed this steps, and I could see the new size, after ssh to box, isnt that enough?
    I mean, why fdisk or gparted?

    PS: I am using official ubuntu xenial box

  3. This was exactly what I needed for resizing a couple of vagrant boxes that were too small for my purposes. Simple stuff, but it was baffling me. Thanks for posting this.