Creating VDI virtual disks for Virtualbox machines (with Vagrant)
When vagrant create Virtualbox machines, disks are created with VMDK format. Therefore, the VDI format has some interesting advantages. This recipe shows a setup to create VDI disks instead VMDK.
The process requires two steps: create and attach disk to the virtual controller. In the Vagrantfile we need to do it in the up if the disk file not exists yet.
The following is a working Vagrantfile using the described setup:
VAGRANTFILE_API_VERSION = "2"
HOME_DISK = "/var/home.vdi"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "deb/jessie-i386"
config.vm.provider :virtualbox do |vb|
if ARGV[0] == "up" && ! File.exist?(HOME_DISK)
vb.customize ['createhd',
'--filename', HOME_DISK,
'--format', 'VDI',
'--size', 50000]
vb.customize ['storageattach', :id,
'--storagectl', 'SATA Controller',
'--port', 0,
'--device', 0,
'--type', 'hdd',
'--medium', HOME_DISK]
end
end
end
WARNING: Vagrant will delete attacked virtual disk when you issue command vagrant destroy!.
[ show comments ]
blog comments powered by Disqus