in WordPress

How to Easily Increase Memory on your Vagrant Virtual Machine

This assumes you are using VirtualBox as your provider, which you are if you’re using a pre-built vagrant configuration like I am with VVV.

I was running out of RAM and crashing my VM while trying to import a 9MB WXR file into a WordPress install.

First, I tried adding a swapfile so I could get some virtual memory. I was able to do that with these instructions from Digital Ocean, but I wasn’t sure how to make it persistent after a vagrant destroy and didn’t want to have to set this up every time I booted up the VM.

Finally, I found this thread in the issues for VVV with the answer.

Create a Customfile in the same directory as your Vagrantfile, and add the contents below, changing 2048 to be whatever value you want to increase your VM’s RAM to.

config.vm.provider :virtualbox do |v|
  v.customize ["modifyvm", :id, "--memory", 2048]

Save the file, and then do a vagrant reload and you should be able to verify with top or free -m that you now have some additional memory in the VM.

I went with 2GB. There has been some discussion of increasing the default in VVV from 512MB, however I think that would be an issue for people on laptops, especially running MacBook Air’s with only 4GB of RAM.

Write a Comment


  1. I’m starting out with vagrant and did virtually the same things you mentioned, adding swap space and then memory, thought i’d mention that in newer versions of vagrant you can add these lines to the vagrant file to add 2G (2046MB) and make it multi-core (2 cpus)

    config.vm.provider “virtualbox” do |vb|
    # # Display the VirtualBox GUI when booting the machine
    # vb.gui = true
    # # Customize the amount of memory on the VM:
    vb.memory = “2048”
    vb.cpus = 2

    • Thanks Joe, I agree that’s a good way to do it. The primary reason for using the Customfile is for Vagrantfiles that you may not have control over, which is my case here. I’d have to manage the updates to the Vagrantfile myself whenever I update the Vagrantfile from a git repo. Customfile allows me to modify it outside of the repo.