how to map a folder in my VM to my local machine

13,763

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

In your Vagrantfile, you should have the following

Vagrant.configure("2") do |config|
  # other config here

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

NOTE: The first parameter is a path to a directory on the host machine. If the path is relative, it is relative to the project root. The second parameter must be an absolute path of where to share the folder within the guest machine. This folder will be created (recursively, if it must) if it doesn't exist.

Other options

Option 1

Recommended sshfs Install sshfs package, mount a path on the host via ssh, for example, mount the $HOME/project to /srv/www on the guest

sshfs user@host:~/project /srv/www

To unmount sshfs

fusermount -u /mnt/sshfs

/srv/www on the guest appears as if it is local.

Option 2

NFS See => Vagrant - NFS

Share:
13,763

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I've got a devbox VM running via vagrant and virtualbox. I'd like to have it just run as a web server and do all my work on my local machine (where my dev tools are).

    I've seen this done before, where the VM has an application folder that points to the host machine's folder, and whenever changes are made on the local machine (i.e. via Sublime/vim) they are automatically updated on the VM.

    The VM is running a Heroku image (which I believe runs on Ubuntu). The host machine is also Ubuntu 13.04