Archive

Posts Tagged ‘virtualbox’

Vagrant was unable to communicate with the guest machine

October 23, 2016 3 comments

Problem:
I was setting up vagrant on an old laptop running debian 8. I also had virtualbox installed. I ran into the following error when trying to set up an ubuntu vm.

$ vagrant init ubuntu/trusty32
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty32' is up to date...
==> default: Setting the name of the VM: flaskbox_default_1477256195436_10223
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

The main reason for this was because the networking on ubuntu was not working.

Solution:
The fix was to restart the network interface on the ubuntu box.

To do this I had to log into the box via the gui interface using virtualbox or uncommenting “vb.gui=true” in the Vagrantfile.

After connecting I ran the following commands

$ sudo ifdown eth0
$ sudo ifup eth0

I then made sure that I could ping google.com and the host box. Now I needed to enable this when the machine booted. That meant adding the same command to /etc/rc.local

$ less /etc/rc.local
ifdown eth0
ifup eth0

exit 0

I now did a test run on ubuntu/precise32. This worked well and vagrant was now working as expected. Trying the same on ubuntu/trusty32 resulted in a timeout once again. This meant that I had to add the following to the Vagrantfile

  # For ubuntu/trusty32 the box takes a while to boot up.
  # Default timeout is 300 seconds.
  config.vm.boot_timeout = 600

Now both boxes are able to come up even after reboot.

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty32' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 4.3.36
    default: VirtualBox Version: 5.1
==> default: Mounting shared folders...
    default: /vagrant => /home/rodnee/boxes/testbox
$ vagrant ssh
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-100-generic i686)

 * Documentation:  https://help.ubuntu.com/

  System information as of Sun Oct 23 21:21:41 UTC 2016

  System load:  0.25              Processes:           81
  Usage of /:   3.3% of 39.34GB   Users logged in:     0
  Memory usage: 15%               IP address for eth0: 10.0.2.15
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.


Last login: Sun Oct 23 21:12:08 2016 from 10.0.2.2
vagrant@vagrant-ubuntu-trusty-32:~$ exit
logout
Connection to 127.0.0.1 closed.
$ vagrant halt
==> default: Attempting graceful shutdown of VM...

Note:
You would have to log into a new box the very first time to bring up the network interface. The new changes will persist after a reboot.

Sources:
This took me so long to fix and I went down so many different rabbit holes that I can’t quite say that there was a definitive source that helped me out.

Lessons learnt
1. Installing the latest version of virtualbox did not work on debian 8 (stretch). I needed to stick with what came with the distribution.
2. I did not need to install virtualbox-guest-additions as it already comes with virtualbox.
3. There is no need to change the Network settings on virtualbox. The default settings for NAT work just fine and were not part of the problem.

# Packages that I needed to install
$ sudo apt-get install virtualbox virtualbox-guest-dkms dkms
$ sudo apt-get install vagrant
Advertisements

Specify a default provider for vagrant

May 1, 2016 Leave a comment

Problem:
I got tired of specifying the provider. The default provider was vmware_fusion.

$ vagrant up --provider virtualbox

Solution:
As per the documentation.

export VAGRANT_DEFAULT_PROVIDER="virtualbox";

So now all I do is

$ vagrant up

Source:
https://www.vagrantup.com/docs/providers/default.html

Categories: bash, vagrant Tags: ,

Vagrant – Setting up an Ubuntu box on Mac OS X

August 21, 2015 Leave a comment

Problem:
Needed to have an Ubuntu Box on Mac OS X Yosemite.

Solution:
Vagrant + Ubuntu + Virtual Box

$ vagrant init ubuntu/trusty64

$ vagrant up --provider virtualbox

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.3.10
    default: VirtualBox Version: 5.0
==> default: Mounting shared folders...
    default: /vagrant => /Users/rodnee/local_trusty
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.


$ vagrant ssh

Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-62-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Fri Aug 21 09:36:29 UTC 2015

  System load:  0.16              Processes:           92
  Usage of /:   2.9% of 39.34GB   Users logged in:     0
  Memory usage: 18%               IP address for eth0: 10.0.2.15
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud


Last login: Fri Aug 21 09:04:39 2015 from 10.0.2.2
-bash: warning: setlocale: LC_ALL: cannot change locale (en.US): No such file or directory

vagrant@vagrant-ubuntu-trusty-64:~$ exit
logout
Connection to 127.0.0.1 closed.

$ vagrant halt

==> default: Attempting graceful shutdown of VM...

Other commands:
1. To view the boxes that you have on your machine.


$ vagrant box list
ubuntu/trusty64     (virtualbox, 20150817.0.0)
ubuntu64box         (vmware_fusion, 0)

$ vagrant box remove ubuntu64box --provider vmware_fusion
Removing box 'ubuntu64box' (v0) with provider 'vmware_fusion'...

Assumptions:
1. You have VirtualBox installed on your machine.
2. You have Vagrant installed on your machine.

Source:
https://atlas.hashicorp.com/boxes/search?provider=virtualbox
Creating Development Environments with Vagrant by Michael Peacock

Using Oracle with Vagrant

December 6, 2014 Leave a comment

Problem:
This was a major issue for me. I needed Oracle 11g Database on my laptop.

Solution:
One of the possible solutions I took was to use vagrant. (I am pretty much just going to repeat the same steps as per what I got from the website listed in the Sources section below.)

1. Download and install Vagrant
2. Download and install VirtualBox
3. Download the Oracle 11g zip file for Linux x64
NB. Always download the Linux x64 zip file, even if you are on Windows or Mac OSX.
4. Clone the vagrant-ubuntu-oracle-xe repository from GitHub
git clone git://github.com/hilverd/vagrant-ubuntu-oracle-xe
5. Copy the Oracle 11g zip file to the directory vagrant-ubuntu-oracle-xe expects to find it in
cp ~/Downloads/oracle-xe-11.2.0-1.0.x86_64.rpm.zip ~/vagrant-ubuntu-oracle-xe/modules/oracle/files
6. Install vbguest
vagrant plugin install vagrant-vbguest
7. Invoke Vagrant to install and configure Oracle 11g
cd ~/vagrant-ubuntu-oracle-xe
vagrant up

After a few minutes your local machine will be running an Oracle 11g server on a virtual instance of Ubuntu 12.04

Well… not exactly.
1. I had run out of space on my / partition. I couldn’t install the new linux header files that were needed. The quickest thing for me was to format my machine. This time round I gave a bit more GBs to / partition.
2. Added some mirrors to /etc/apt/sources.list
3. root> apt-get update
4. First mistake I made was not to do apt-get dist-upgrade
5. So, oblivious of that, I followed steps 1 to 7, but vagrant up brought more errors
6. The kernel version on my machine and the latest linux-headers- being seen by virtual box were not the same. I was getting an error similar to this. (It was late and I did not have the presence of mind to save the errors. Sorry.)
$ VBoxManage --version
WARNING: The character device /dev/vboxdrv does not exist.
Please install the virtualbox-ose-dkms package and the appropriate
headers, most likely linux-headers-generic

You will not be able to start VMs until this problem is fixed.
X.X.XX_DebianXXXXX

7. Googled a bit. All references to above error were advising the OPs to do the following
apt-get install linux-headers-$(uname -r)
8. But above did not work since I could not find the linux-headers for the current system version that I had.
9. After 2 or 4 hours, I realised that I needed to get my kernel (3.14) to the same version as what was installed (3.16), so read about configuring kernels but the steps were too hard for my already fried brain. At this point I stumbled accross an page explaining what apt-get does. And thus I tried dist-upgrade with the hope that it would upgrade my kernel.
10. Ran the below command
root> apt-get dist-upgrade
11. Once that was done, I rebooted and sure enough my kernel was now 3.16
12. vagrant up now runs
13. So this install would have gone a whole lot more smoothly if I had updgraded my machine before I started this exercise. I’m much older and wiser 🙂

Source:
https://wiki.kuali.org/display/KULRICE/Install+Oracle+11g+using+Vagrant
https://help.ubuntu.com/community/AptGet/Howto