Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move Vagrant VM folder?

Tags:

vagrant

Is there a way to move a vagrant vm folder without having problems with nfs shared folders and /etc/exports?

Trying to move the machine (halted) results in the following error whenever I try to operate on any other box (eg: vagrant up):

==> default: Exporting NFS shared folders...
NFS is reporting that your exports file is invalid. Vagrant does
this check before making any changes to the file. Please correct
the issues below and execute "vagrant reload":

exports:14: path contains non-directory or non-existent components: /Users/[...]/vm
exports:14: no usable directories in export entry
exports:14: using fallback (marked offline): /
like image 454
mettjus Avatar asked Mar 03 '15 17:03

mettjus


1 Answers

I'm a bit late but I just had the same problem and felt like sharing my solution in case someone else stumbles upon this too.

I ended up changing the path in /etc/exports (on the host machine), for example:

# VAGRANT-BEGIN: 501 121121ae-813d-4546-8fbb-f44c591f5529
"/Users/me/wrong/dir" 192.168.3.103 -alldirs -mapall=501:20
# VAGRANT-END: 501 121121ae-813d-4546-8fbb-f44c591f5529

There you can change the path on the host. Then after a vagrant reload it should work.

The path is also stored in .vagrant/machines/default/virtualbox/synced_folders (directory names depending on what provider do you use and whether you use the default machine), I tried changing that first but that's not enough, however, it might confuse Vagrant if you don't change it there too -- to be safe you should change it there too.

Unfortunately I'm not aware of any way to do this without manually changing these files or destroying the box.

like image 117
mpager Avatar answered Oct 03 '22 07:10

mpager