How I can get /vagrant folder on ubuntu/xenial64

后端 未结 5 1376
情歌与酒
情歌与酒 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: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.

提交回复
热议问题