How can I increase disk size on a Vagrant VM?
I found this simplest way to resolve this problem:
Install this plugin:
vagrant plugin install vagrant-disksize
-
Edit the
Vagrantfile
:Vagrant.configure('2') do |config| ... config.vm.box = 'ubuntu/xenial64' config.disksize.size = '50GB' ... end
-
vagrant halt && vagrant up
- Note: this will not work with
vagrant reload
- Note: this will not work with
Personally I think it'll be easier to attach an extra virtual HDD and mount it to a proper mount point, for example /opt
and move your stuff over using rsync
to work around this issue, after all, puppet vagrant boxes are for testing purposes.
Reason why: VBoxManage modifyhd
only works with native VDI image. However, vagrant base boxes are basically exported OVF/OVA using VMDK
format.
See VirtualBox Docs
The
--resize x
option (where x is the desired new total space in megabytes) allows you to change the capacity of an existing image; this adjusts the logical size of a virtual disk without affecting the physical size much.[37] This currently works only for VDI and VHD formats, and only for the dynamically allocated variants, and can only be used to expand (not shrink) the capacity.
To increase the capacity of disk for Vagrant Base Box
Steps are
To be able to resize the HDD, you'll have to convert it to VDI first, e.g.
VBoxManage clonehd in.vmdk out.vdi --format VDI
and then re-attached it (using the GUI is easier).Resize it using
VBoxManage modifyhd box.vdi --resize 15360
which increases the capacity to 15GB.However this only changes the drive capacity, you will have to expand the file system for the guest afterwards. For example, use
resize2fs -p -F DEVICE
for ext{3,4}.