How I can get /vagrant folder on ubuntu/xenial64

后端 未结 5 1513
情歌与酒
情歌与酒 2021-02-20 16:58

I have just installed vagrant box with command:

vagrant init ubuntu/xenial64

and the booted it up with:

vagrant up --provider v         


        
相关标签:
5条回答
  • 2021-02-20 17:01

    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.

    0 讨论(0)
  • 2021-02-20 17:02

    You could try installing the vbguest addition plugin, and see if that helps.

    $ vagrant plugin install vagrant-vbguest
    

    vb-guest plugin repo

    Also, sometimes when you install the vbox on your computer if you dont give permissions to the additional drivers that it wants to install it will not function properly. You might need to re install to make sure that you accept the prompt when asking to install some drivers.

    In case none of this works, you might try to boot withouth a gui, and paste here the output when trying to start the vagrant machine.

    0 讨论(0)
  • 2021-02-20 17:08

    Vagrant by default mounts a /vagrant folder on the guest machine that is synced with the folder where the Vagrantfile is.

    There are some reasons why vagrant couldn't mount your shared folder, the most common is that you don't have the virtualbox drivers correctly installed and initialized.That happens when you don't have your kernel headers on the same version of the virtual box packages.

    First make sure you don't have this line on your Vagrantfile because this will disable the synced folder:

    config.vm.synced_folder ".", "/vagrant", disabled: true

    If you don't have it, it's probably a error with the virtualbox modules on your system, and i would recommend you to check the drivers doing the following steps.

    Destroy your running virtual machine:

    vagrant destroy -f

    You can check your kernel version using:

    uname -r

    After that install the headers for your kernel:

    sudo apt-get install linux-headers-'uname-r'

    Then, install the virtualbox packages for your kernel:

    sudo apt-get install virtualbox virtualbox-dkms virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-additions-iso

    Load the virtualbox drivers:

    sudo modprobe vboxdrv

    Now you can try to mount the virtual machine with vagrant again:

    vagrant up

    Remember that you can reconfigure your vm to have as many shared folders that you want, you can do that with:

    config.vm.synced_folder "src/", "/srv/website"

    The first argument is the path to the folder on the host machine, the second one is where the folder will be present on the guest machine.

    Hope this helps you.

    0 讨论(0)
  • 2021-02-20 17:26

    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.

    0 讨论(0)
  • 2021-02-20 17:26

    For some reason ubuntu/xenial64 doesn't come with a synced /vagrant folder.

    I had to setup my own in the vagrant file:

    config.vm.synced_folder ".", "/vagrant"
    

    The first option is the source (Windows) the second is the target (Ubuntu)

    Vagrant Synced Folders

    0 讨论(0)
提交回复
热议问题