Reputation: 19115
I use the below code to create the second disk. When I start the VM first time its creating the disk. when halt and start the VM again, its trying to create the disk second time and startup failing. I tried with full path name, still running into same problem.
disk = "secondDisk.vdi"
config.vm.provider "virtualbox" do |vb|
unless File.exist?(disk)
vb.customize ['createhd', '--filename',disk , '--variant', 'Fixed', '--size', 1 * 1024]
end
vb.customize ['storageattach', :id, '--storagectl', 'IDE', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk]
end
Any idea why File.exist check not working?
thanks SR
Upvotes: 1
Views: 850
Reputation: 19115
I was able to add the absolute path to resolve this problem.
Here is the snippets I used.
current_dir = File.dirname(File.expand_path(__FILE__))
disk_perfix = 'secondDisk'
disk_ext ='.vdi'
disk = "%s/%s-%02d%s" % [current_dir,disk_perfix, i, disk_ext]
Thanks -SR
Upvotes: 1