2013-09-03 18:08:28 +00:00
|
|
|
---
|
2016-01-19 18:08:53 +00:00
|
|
|
layout: "docs"
|
2013-09-06 16:50:43 +00:00
|
|
|
page_title: "Configuration - VirtualBox Provider"
|
2016-01-19 18:08:53 +00:00
|
|
|
sidebar_current: "providers-virtualbox-configuration"
|
|
|
|
description: |-
|
|
|
|
The VirtualBox provider exposes some additional configuration options
|
|
|
|
that allow you to more finely control your VirtualBox-powered Vagrant
|
|
|
|
environments.
|
2013-09-03 18:08:28 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Configuration
|
|
|
|
|
|
|
|
The VirtualBox provider exposes some additional configuration options
|
|
|
|
that allow you to more finely control your VirtualBox-powered Vagrant
|
|
|
|
environments.
|
|
|
|
|
|
|
|
## GUI vs. Headless
|
|
|
|
|
|
|
|
By default, VirtualBox machines are started in headless mode, meaning
|
|
|
|
there is no UI for the machines visible on the host machine. Sometimes,
|
|
|
|
you want to have a UI. Common use cases include wanting to see a browser
|
|
|
|
that may be running in the machine, or debugging a strange boot issue.
|
|
|
|
You can easily tell the VirtualBox provider to boot with a GUI:
|
|
|
|
|
|
|
|
```
|
|
|
|
config.vm.provider "virtualbox" do |v|
|
|
|
|
v.gui = true
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
## Virtual Machine Name
|
|
|
|
|
|
|
|
You can customize the name that appears in the VirtualBox GUI by
|
|
|
|
setting the `name` property. By default, Vagrant sets it to the containing
|
|
|
|
folder of the Vagrantfile plus a timestamp of when the machine was created.
|
|
|
|
By setting another name, your VM can be more easily identified.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
config.vm.provider "virtualbox" do |v|
|
|
|
|
v.name = "my_vm"
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2015-06-08 16:03:03 +00:00
|
|
|
## Linked Clones
|
|
|
|
|
|
|
|
By default new machines are created by importing the base box. For large
|
|
|
|
boxes this produces a large overhead in terms of time (the import operation)
|
|
|
|
and space (the new machine contains a copy of the base box's image).
|
|
|
|
Using linked clones can drastically reduce this overhead.
|
|
|
|
|
|
|
|
Linked clones are based on a master VM, which is generated by importing the
|
2015-12-24 20:05:16 +00:00
|
|
|
base box only once the first time it is required. For the linked clones only
|
2015-06-08 16:03:03 +00:00
|
|
|
differencing disk images are created where the parent disk image belongs to
|
|
|
|
the master VM.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
config.vm.provider "virtualbox" do |v|
|
2015-12-22 00:00:47 +00:00
|
|
|
v.linked_clone = true
|
2015-06-08 16:03:03 +00:00
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2015-12-22 08:47:01 +00:00
|
|
|
To have backward compatibility:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
config.vm.provider 'virtualbox' do |v|
|
2017-02-01 21:22:23 +00:00
|
|
|
v.linked_clone = true if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.8.0')
|
2015-12-22 08:47:01 +00:00
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2016-10-08 16:37:43 +00:00
|
|
|
If you do not want backward compatibility and want to force users to
|
2015-12-24 20:05:16 +00:00
|
|
|
support linked cloning, you can use `Vagrant.require_version` with 1.8.
|
|
|
|
|
2015-06-08 16:03:03 +00:00
|
|
|
<div class="alert alert-info">
|
2016-01-19 19:54:13 +00:00
|
|
|
<strong>Note:</strong> the generated master VMs are currently not removed
|
|
|
|
automatically by Vagrant. This has to be done manually. However, a master
|
|
|
|
VM can only be removed when there are no linked clones connected to it.
|
2015-06-08 16:03:03 +00:00
|
|
|
</div>
|
|
|
|
|
2013-09-03 18:08:28 +00:00
|
|
|
## VBoxManage Customizations
|
|
|
|
|
2016-01-19 18:08:53 +00:00
|
|
|
[VBoxManage](https://www.virtualbox.org/manual/ch08.html) is a utility that can
|
2013-09-03 18:08:28 +00:00
|
|
|
be used to make modifications to VirtualBox virtual machines from the command
|
|
|
|
line.
|
|
|
|
|
|
|
|
Vagrant exposes a way to call any command against VBoxManage just prior
|
|
|
|
to booting the machine:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
config.vm.provider "virtualbox" do |v|
|
|
|
|
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
In the example above, the VM is modified to have a host CPU execution
|
|
|
|
cap of 50%, meaning that no matter how much CPU is used in the VM, no
|
|
|
|
more than 50% would be used on your own host machine. Some details:
|
|
|
|
|
|
|
|
* The `:id` special parameter is replaced with the ID of the virtual
|
|
|
|
machine being created, so when a VBoxManage command requires an ID, you
|
|
|
|
can pass this special parameter.
|
|
|
|
|
|
|
|
* Multiple `customize` directives can be used. They will be executed in the
|
|
|
|
order given.
|
2013-10-28 03:43:33 +00:00
|
|
|
|
2014-01-10 17:41:23 +00:00
|
|
|
There are some convenience shortcuts for memory and CPU settings:
|
2013-10-28 03:43:33 +00:00
|
|
|
|
|
|
|
```ruby
|
|
|
|
config.vm.provider "virtualbox" do |v|
|
|
|
|
v.memory = 1024
|
2014-01-10 17:41:23 +00:00
|
|
|
v.cpus = 2
|
2013-10-28 03:43:33 +00:00
|
|
|
end
|
|
|
|
```
|