9

The /vagrant directory is empty. It should contain the workspace where my Vagrantfile is located. I can cd /vagrant, but it's empty.


Vagrantfile

VAGRANTFILE_API_VERSION = '2'
VAGRANT_BOX_NAME = 'nomades.local'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = 'bento/centos-6.7'
  config.vm.box_check_update = false
  config.vm.hostname = VAGRANT_BOX_NAME

  config.vm.define VAGRANT_BOX_NAME do |dev|
    dev.vm.provider 'virtualbox' do |v|
      v.name = VAGRANT_BOX_NAME
      v.memory = 512
      v.cpus = 2
      v.gui = true
      v.customize ['modifyvm', :id, '--ioapic', 'on', '--vram', '16']
    end

    # Réseau (penser à configurer son /etc/hosts pointant vers cette ip)
    dev.vm.network 'private_network', ip: '192.168.12.2'

    # In order to use VPN
    # dev.vm.network 'public_network', ip: '172.32.0.101'

    # Provision
    dev.vm.provision "ansible" do |ansible|
      ansible.groups = {
          'vagrant' => [VAGRANT_BOX_NAME],
          'servers' => [VAGRANT_BOX_NAME],
      }
      ansible.playbook = 'provision/provision.yml'
      ansible.sudo = true
    end
  end
end
Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
sab
  • 4,352
  • 7
  • 36
  • 60
  • Does this answer your question? [/vagrant not populated with files](https://stackoverflow.com/questions/36270066/vagrant-not-populated-with-files) – ggorlen Mar 28 '20 at 00:37

3 Answers3

11

This happens when vagrant can't modify /etc/fstab and tries to mount the current working directory from the host. Make sure it has permissions to mount the directory.

Run this on the Vagrant guest VM, then logout.

$ sudo /etc/init.d/vboxadd setup

Run this on the host.

$ sudo vagrant reload
$ vagrant ssh
Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
acsrujan
  • 1,011
  • 11
  • 18
2

This issue happened to me after manually rebooting the VM (i.e. sudo reboot).

Restarting the machine from the host solved the problem for me:

$ vagrant halt
$ vagrant up
michael-slx
  • 665
  • 9
  • 15
0

you need to define below line in the vagrantfile, . means current directory

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

rikki
  • 51
  • 9
  • AFAIK there is no extra definition necessary for the /vagrant directory, because it is automatically mapped to current directory. The config says, you need to do (only?) if you need "additional" shares. – Markus Zeller May 29 '19 at 09:20