How to add storage settings to Vagrant file? - virtualbox

I have created a VM using vagrant and tried to insert a cd, when realized that there is no such device to read it installed.
An option would be to go to my provider UI and through settings add what I need.
I want to know if there is any way to insert this setting (add a cdrom device to VM) into the vagrant file.
My provider is VirtualBox.
>>UPDATE
Mixing info from here and here, and extending some code example already existing in Vagrantfile I came up with
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
...
...
config.vm.provider :virtualbox do |vb|
vb.customize ["storagectl", :id, "--name", "IDEController", "--add", "ide"]
vb.customize ["storageattach", :id, "--storagectl", "IDEController", "--port", "0", "--device", "0", "--type", "dvddrive", "--medium", "none"]
vb.customize ["modifyvm", :id, "--boot1", "disk", "--boot2", "dvd"]
end
...
...
end
in the Vagrantfile.
The problem is that now, when attempting to perform vagrant reload, I get
VBoxManage.exe: error: No storage device attached to device slot 0 on port 0

--medium none is to telling VirtualBox to delete that DVD, please use --medium emptydrive.
See this link https://groups.google.com/forum/#!topic/vagrant-up/Z_KruTTN0vk and medium help:
--medium
Specifies what is to be attached. The following values are supported:
"none": Any existing device should be removed from the given slot.
"emptydrive": For a virtual DVD or floppy drive only, this makes the
device slot behaves like a removable drive into which no media has
been inserted.

Related

Vagrant, Ember-cli, Windows 8.1, Ubuntu. Livereload doesn't work! It doesn't detect changes when I save from Windows

I have this VagrantFile:
Vagrant.configure("2") do |config|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
config.vm.box = "ubuntu/trusty64"
# Configurate the virtual machine to use 2GB of RAM
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
# Forward the Rails server default port to the host
config.vm.network :forwarded_port, guest: 4200, host: 4200
config.vm.network :forwarded_port, guest: 35729, host: 35729
Everything works good, in my Windows I can visit http://localhost:4200 and it works. But, there is a big but.
I have the ember's project files in a Windows folder shared with vagrant.
If I save files of my ember's project in Windows I can't have livereload, and in my vagrant ssh I even can't view the changes detected.
If I go with vagrant ssh and use nano application.hbs and then save something new it detect changes and livereload works in my Chrome's window on Windows.
What the hell is the problem?
The way Vagrant syncs directories between your desktop and the VM will break the default mechanism ember-cli uses to watch files and cause issues when updates are subsequently compiled.
To restore this functionality, you can either add the following lines to the '.ember-cli' file
"liveReload": true,
"watcher": "polling"
or invoke the serve command using the fallback polling watcher.
ember serve --watcher polling
I fixed that with this: ember serve --watcher polling. NFS sharing with Vagrant doesn't work on Windows.
I believe this may help you: http://www.ember-cli.com/user-guide/#usage-with-vagrant
Seems like you didn't fallback to polling watcher.
And you didn't also use NFS since it's not in your config. For windows user, you should use the winnfsd plugin and install with vagrant plugin install vagrant-winnfsd

"STDERR: The guest machine entered an invalid state while waiting for it to boot." error while doing vagrant up

I'm getting the following error when doing vagrant up.
STDERR: The guest machine entered an invalid state while waiting for it to boot. Valid states are 'starting, running'. The machine is in the 'poweroff' state. Please verify everything is configured properly and try again.
I'm using vagrant 1.7.2 and virtual box 4.3.22
When I try to start VM using VB GUI, my system simply crashes with blue screen of death. Any ideas on on how to solve this.
I had the same problem using vagrant 1.8.1 and virtualbox 5.0.12. After some research, I found out that you cannot run a 64 bit VM in your PC if hardware acceleration (VT-x) is disabled. You can turn this setting on/off in the BIOS.
In my case, this was not an option cause I was running vagrant from another VM which doesn't support this option so I used 32 bit box and disabled hardware acceleration. To do this, add this to your Vagrantfile configuration:
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--hwvirtex", "off"]
end
This worked for me.

Allow vagrant to access host internet

Im using virtualbox + ubuntu + vagrant.
However im not able to ping or wget any url. Please guide me on how I can allow the VM to access my host machine's internet?
this works for me.
Configure the Vagrantfile with this.
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
I hope this help.

Change default disk controller in Vagrant

I have some network-booted (PXE/TFTP) test/dev vms that are created and run using Vagrant.
However, by default Vagrant/Virtualbox adds SATA controller while some of those vms run older Linux distros that do not understand SATA and require virtual IDE controllers.
I can't seem to find the way to change controller type in Virtualbox that I could customize in Vagrant.
Is there a way to specify disk controller type in Vagrant (or, not so preferably, in underlying Virtualbox itself) using smth like http://www.virtualbox.org/manual/ch08.html#vboxmanage-storagectl ?
If you know the exact commands for VBoxManage, you could try something like:
Vagrant.configure("2") do |config|
# ...
config.vm.provider "virtualbox" do |v|
v.customize ["storagectl", :id, "--name", "SATA Controller", "--remove"]
v.customize ["storagectl", :id, "--name", "IDE Controller", "--add", ...]
end
end

Vagrant: Network type 'bridged' is invalid. Please use a valid network type

Can anyone explain why I am getting the following error
"Vagrant: Network type 'bridged' is invalid. Please use a valid network type."
when I try to bring vagrant up on Virtual Box with the following Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.hostname = "gitserver"
config.berkshelf.enabled = true
config.vm.box = "centos57"
config.vm.box_url = "http://xx.xx.xx.xx/os/centos-5.7-x86_64.box"
config.vm.network :bridged, :bridge => 'eth0'
# Provision VM using chef
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "mysqlserver"
end
config.vm.customize ["modifyvm", :id, "--memory", 1024]
end
I have tried all possible combinations with bridged configuration, but it simply does not like it. I cannot find any additional info as to why. Any help here would be hugely appreciated.
Since you are using a Vagrant config file version 2 (and therefore Vagrant 1.1+) instead of :bridge there is now the new type :public_network.
To use v1 code, you can insert it into a config 1 block like this:
Vagrant.configure("1") do |config|
config.vm.network :bridged, :bridge => 'eth0'
end
For Vagrant 1.3.5 in used the following:
config.vm.network :public_network, bridge: "en0: Wi-Fi (AirPort)"
It worked for me.
I am installing vagrant on ubuntu 10.04 with Virtualbox VirtualBox 4.1.24 from https://www.virtualbox.org/wiki/Linux_Downloads and then downloaded recent version of vagrant.
$ vagrant -v
Vagrant version 1.2.2
$ dpkg -l virtualbox*
ii virtualbox-4.1 4.1.26-84997~U Oracle VM VirtualBox
In order to use bridge network and specifically wifi i just added the line below inside Vagrantfile
config.vm.network :public_network, :public_network => "wlan0"
When you will do
$ vagrant up
You will see option asking for device for bridge interface you can use 1 for wlan0. Hope it helps.