If an error 'initialize': negative string size (or size too big)
occurs, the solution is to remove the index file in ~\.vagrant.d\data\machine-index
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. Moreover, most Vagrant boxes use VMDK disks which cannot be resized!
This plugin allows to resize the disk size.
vagrant plugin install vagrant-disksize
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/xenial64'
config.disksize.size = '50GB'
end
Depending on the guest, you may need to resize the partition and the filesystem from within the guest. At present the plugin only resizes the underlying disk.
-
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:
VBoxManage clonemedium "box-disk1.vmdk" "cloned.vdi" --format vdi
-
Now we can easily resize this VDI disk, e.g. to 50 GB:
VBoxManage modifymedium "cloned.vdi" --resize 51200
If we want a Fixed
size, we can now make a new clone with the option --variant Fixed
(the disk can't be resized anymore).
-
Then 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 by replacing the VMDK disk by this new one in VirtualBox.
-
The last step is to resize the guest filesystem partition with the new available disk space (not explained here)
An other alternative is to create a new disk VBoxManage createmedium --filenane "new_disk.vdi" --format VDI --size 51200
Then, to attach this disk to the VM in addition to the previous one.