Mike
Mike

Reputation: 638

How to make files placed in vagrantfile directory show up in VM

I'm having a lot of trouble transferring files to my VM. I tried vagrant scp but I couldn't get it to work. I also tried using github which isn't a very elegant solution but it does work. I would like to place files in my vagrantfile directory and have them show up in my VM but that's not working. I tried vagrant reload but still they won't show up in VM. How do I configure files to show up in VM when placed in vagrantfile directory? I'm using mac osx with ubuntu/trusty32 vm. Update: I got it to work by adding this to the vagrantfile

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

where src/ is the home directory i want to share and /srv/website is the vm directory i want to share to. then i exited out of my vm and used

vagrant reload

and then it worked

Upvotes: 0

Views: 76

Answers (1)

Frederic Henri
Frederic Henri

Reputation: 53703

vagrant sync folder is I think the best and simplest way to achieve this.

By default you have the directory where you have Vagrantfile mapped with /vagrant directory within the VM. so any files you create there will automatically be pushed into this /vagrant VM directory

You can also synchronize any other directory - if you concern about VM performance issue, you can use nfs type to speed up transfer

config.vm.synced_folder "src/", "/srv/website", type: "nfs"

In this example any files from your src/ folder within the vagrant project will be synchronized to the /srv/website folder of the VM and the files will be transferred using nfs type

Upvotes: 1

Related Questions