Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can get /vagrant folder on ubuntu/xenial64

Tags:

vagrant

ubuntu

I have just installed vagrant box with command:

vagrant init ubuntu/xenial64

and the booted it up with:

vagrant up --provider virtualbox

after ssh-ing I can not find folder /vagrant

What I am doing wrong?

According to documentation there should be /vagrant folder:

By default, Vagrant will share your project directory (the directory with the Vagrantfile) to /vagrant.

Here is a screenshot where is obvious that there is no /vagrant folder

My host environment is:

  • windows 7
  • Vagrant version 1.8.1
  • Vbox version 5.0.20r106931

Here is my Vagrant file:

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|

  config.vm.box = "ubuntu/xenial64"

  config.vm.provision "shell", path: "provision.sh"

  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true

    # Customize the amount of memory on the VM:
    vb.memory = "4096"
    vb.cpus = "2"

    # Hack for nom global install
    # https://github.com/npm/npm/issues/7308
    vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]

  end
end

and here is my provisioning file:

echo "------------------------------"
echo "--- Updating packages list ---"
echo "------------------------------"
apt-get -y update

echo "-----------------------"
echo "--- Installing curl ---"
echo "-----------------------"
apt-get -y install curl

echo "----------------------"
echo "--- Installing git ---"
echo "----------------------"
apt-get -y install git

echo "-----------------------------"
echo "--- Installing python-pip ---"
echo "-----------------------------"
apt-get -y install python-pip
yes | pip install --upgrade pip

echo "--------------------------"
echo "--- Installing node.js ---"
echo "--------------------------"
apt-get -y install  nodejs

echo "----------------------"
echo "--- Installing npm ---"
echo "----------------------"
apt-get -y install npm
like image 420
gandra404 Avatar asked May 17 '16 17:05

gandra404


People also ask

Where is the vagrant directory?

Explore the synced folder Tip: When you vagrant ssh into your machine, you're in /home/vagrant , which is a different directory from the synced /vagrant directory. Believe it or not, the Vagrantfile that you see inside the virtual machine is actually the same Vagrantfile that is on your actual host machine.


2 Answers

Update:

This problem was finally fixed in version v20160921.0.0 and higher of the official 16.04 vagrant box. The release before that v20160909.0.0 is also fixed but has another unrelated issue, as pointed out by Poma in the comments.

You can use the following command to download the new version and also replace your old VM instance with a fresh one. However, upgrading the box wipes your original VM instance.

vagrant box update

If you don't want to wipe your VM for some reason, you can still apply my original fixes below.

Original Post:

Apparently the official ubuntu/xenial64 image is broken, as indicated in this bug report on launchpad.

Here's a quote from the comments by Louis Zuckerman with all the issues which are still unfixed as of version 20160627.0.0 from what I could tell:

There are a number of issues with the official vagrant box for xenial:

  1. necessary packages are missing (synced folders not working, no config management)
  2. default /vagrant synced folder is disabled
  3. vm name is static, so you can only have one instance of the box on a host

[...]

These steps fixed issues 1 and 2 for me:

  1. ssh into the box and install the missing guest additions manually

    vagrant ssh
    sudo apt-get install virtualbox-guest-utils
    exit 
    
  2. manually add the missing mountpoint to your Vagrantfile

    config.vm.synced_folder ".", "/vagrant/" # fix broken ubuntu/xenial64 image
    

To fix the third issue you have to give a unique name to the box manually by adding a provider-specific option for VirtualBox to your Vagrantfile.

config.vm.provider "virtualbox" do |vb|
  vb.name = "This_Name_Is_Unique_For_This_Machine"
end

There is a more detailed discussion of this issue here as pointed out in the comments to this answer.

like image 54
mschwaig Avatar answered Oct 13 '22 15:10

mschwaig


Is there a reason people are not using bento/ubuntu-16.04 ?

See this response: https://github.com/mitchellh/vagrant/issues/7155

the boxes published by canonical under the ubuntu namespace for 16.04 are very broken. They do not follow the recommended guides for how to build a Vagrant box, and they are missing key components such as guest additions, required packages, or they do things like hardcode the hostname to make running concurrent VMs impossible. ... In general, users have had more success with the boxes under the bento namespaces. A common misconception is that a namespace like "ubuntu" represents the canonical space for Ubuntu boxes. This is untrue.

There seems to be many reasons NOT to use the ubuntu/xenial64 boxes and just use a working box from the bento namespace instead of trying to hack the ubuntu namespace boxes to work. The Ubuntu brand may be more comfortable for some people to see, but I think it's broken with Vagrant.

like image 27
codetricity Avatar answered Oct 13 '22 14:10

codetricity