Increasing VM maximum “hard drive” size

I'm using vagrant backed by VirtualBox to create a development setup (using the bento/ubuntu-18.04 box). To truly test the application, it needs a lot of data in a postgreSQL database: more than there is space for in the box we're using.

Some googling suggests it's actually really hard to just give the box more space. Using the vagrant-disksize plugin only increases the size of the "hard disk": you then need to use several different tools (one of which seems to be interactive i.e. tough to script) to extend the file system and then the partition to make use of that additional size. For me, the last step also fails, presumably because I'm trying to extend a partition which an OS is currently running on. The backend VirtualBox seems to require you to shut down, export the VM image in a different format, then edit it and re-load it.

Am I crazy thinking that this should be a single config option which you can set before the machine gets set up?

I also tried setting the postgres data directory to use a directory synced with the host, but there were permission issues: you can't change file permissions in synced directories (they're locked to the SSH user).

4 thoughts on “Increasing VM maximum “hard drive” size”

  1. You can resize the VM, but you will need to resize the partition to handle it. The additional option you aren’t mentioning is mounted vagrant folders that allow you to use the host OS’s storage space. I’m not sure if this treats it as a mounted folder or something else, so you may want to look into that.

  2. For anyone coming across this in future, the `vagrant-disksize` plugin will resize the disk, but not the logical volume or the partition. How you resize those depends on the box (i.e. which operating system the VM is running and the tools it has available), but here’s a solution for ubuntu by [PolarGoose]( from a [related GitHub issue](

    Vagrant.configure(“2”) do |config| = “hashicorp/bionic64”

    # Extend disk size
    config.disksize.size = ‘200GB’
    config.vm.provision “shell”, inline: <<-SHELL parted /dev/sda resizepart 1 100% pvresize /dev/sda1 lvresize -rl +100%FREE /dev/mapper/vagrant--vg-root SHELL end ``` It worked for me using the `bento/ubuntu-18.04` box.

  3. The vagrant-disksize plugin works, as others have suggested but if you use this box heavily, I’d recommend using Packer to create your own box using the image you’re using as a base, it’s pretty easy and allows a lot of customization. You can also store the created box on your local machine or use an NFS or S3 to share it.


Leave a Comment