I've been looking for hours on where I can find a box that is --variant 'fixed' instead of growable from start, or how I can change a existing Ubuntu 14.04 box to be fixed as it seems like all the VirtualBox boxes are set to be dynamic from start.
VboxManage seems to be an alternative if I want to clone the VDI/VMDK manually to be fixed size, but what I'm looking for is a way to make the box fixed from start, during the build of the VM. In other words - I don't want to convert it manully afterwards, it should be handled in the Vagrantfile.
Using this box
https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/14.04/providers/virtualbox.box
Host system
Ubuntu 14.04
Thanks!
Hi @enoch85
Thank you for opening an issue. I think you want to use the modifyvm command as such:
Vagrant.configure("2") do |config|
# ... (other config)
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyhd", "<disk id>", "--resize", "<size in megabytes>"]
end
end
You should be able to use the --variant flag there.
Please let me know if you have any questions!
Thanks @sethvargo! Maybe I got this wrong, but I get this output:
A customization command failed:
["modifyhd", "<disk id>", "--resize", "40000", "--variant", "Fixed"]
The following error was experienced:
#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyhd", "<disk id>", "--resize", "40000", "--variant", "Fixed"]
Stderr: Oracle VM VirtualBox Command Line Management Interface Version 4.3.10_Ubuntu
(C) 2005-2015 Oracle Corporation
All rights reserved.
Usage:
VBoxManage modifyhd <uuid|filename>
[--type normal|writethrough|immutable|shareable|
readonly|multiattach]
[--autoreset on|off]
[--property <name=[value]>]
[--compact]
[--resize <megabytes>|--resizebyte <bytes>]
Syntax error: unknown option: --variant
>
Please fix this customization and try again.
@enoch85 it looks like you want --type immutable. I'm not super familiar with the vboxmanage interface, but the list of options are there. It's possible they have changed.
To solve the problem I modified the vagrant code. To the bottom of function import(...) in providers\virtualbox\driver\version_5_1.rb, I added the below:
`
id = get_machine_id specified_name
#change disks to VDI and set them to be full sized to speed up performance
info = execute("showvminfo", id, "--machinereadable", retryable: true)
info.split("\n").each do |line|
if line =~ /^storagecontrollername\d+="(.+?)"$/
@controller = $1.to_s
#use str.scan(str) to customize the controller name
end
if line =~ /Controller-0-0"="(.+?)"$/
@box_path = $1.to_s
end
if line =~ /Controller-ImageUUID-0-0"="(.+?)"$/
@box_uuid = $1.to_s
end
end
env[:ui].info "controller: #{@controller} path: #{@box_path} uuid; #{@box_uuid}"
clone_path = "#{@box_path}.vdi"
r = execute("clonehd", "--variant","Fixed", "--format","VDI", @box_uuid , clone_path)
env[:ui].info "clone hard drive: #{r}"
r = execute("storageattach", id, "--storagectl", @controller, "--port","0", "--device","0","--type","hdd", "--nonrotational","on", "--medium",clone_path)
env[:ui].info "attach: #{r}"
r = raw("del #{@box_path}")
env[:ui].info "removed old VMDK: #{r}"
id
`
You can use the plugin
https://github.com/sprotheroe/vagrant-disksize
$ VBoxManage modifyhd
Usage:
VBoxManage modifymedium [disk|dvd|floppy] <uuid|filename>
[--type normal|writethrough|immutable|shareable|
readonly|multiattach]
[--autoreset on|off]
[--property <name=[value]>]
[--compact]
[--resize <megabytes>|--resizebyte <bytes>]
[--move <path]
[--description <description string>]
I'm not clear ln the logic of closing this issue. I would presume that code offered by vzlatkin on Apr 9, 2017 adding the option: --variant would be an upgrade to Vagrant. What exactly was the logic behind closing this issue? (or wait.. am I the only person profoundly disappointed with the speed of my virtualbox devices? )
update: anybody know if "--type immutable" == "--variant", "Fixed" ?? No way. immutable means updated data on the drive isn't stored when the box is shut down.
oops. Looks like modifymedium isn't the correct method.
$ vboxmanage createmedium
Usage:
VBoxManage createmedium [disk|dvd|floppy] --filename <filename>
[--size <megabytes>|--sizebyte <bytes>]
[--diffparent <uuid>|<filename>
[--format VDI|VMDK|VHD] (default: VDI)
[--variant Standard,Fixed,Split2G,Stream,ESX]
this makes more sense...
Many thanks to the Vagrant team for a pretty awesome product....
vb.customize ["modifyhd", "
how can i find disk ID
below is error and my vagrantfile
**=> control: Running 'pre-boot' VM customizations...
A customization command failed:
["modifyhd", "a89f1136-115c-4efb-96b8-2ffc9c9cd906", "--resize", "20408"]
The following error was experienced:
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyhd", "a89f1136-115c-4efb-96b8-2ffc9c9cd906", "--resize", "20408"]
Stderr: VBoxManage: error: The given path 'a89f1136-115c-4efb-96b8-2ffc9c9cd906' is not fully qualified
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 179 of file VBoxManageDisk.cpp
>
Please fix this customization and try again.
01:00:15 @ My_MAC: test $ cat Vagrantfile
Vagrant.configure(2) do |config|
config.hostmanager.enabled = true
config.vm.box = "centos/7"
config.vm.define "control", primary: true do |h|
config.disksize.size = "20GB"
h.vm.network "private_network", ip: "192.168.135.10"
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 500]
v.customize ["modifyvm", :id, "--name", "control"]
v.customize ["modifyhd", "a89f1136-115c-4efb-96b8-2ffc9c9cd906", "--resize", "20408"]
end
end
end**
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
You can use the plugin
https://github.com/sprotheroe/vagrant-disksize