Windows – Reconnect synced folders from Vagrant after VirtualBox restart

puppetUbuntuvagrantvirtualboxwindows

I have created a puppet/vagrant/VirtualBox generated installation of Ubuntu running on a Windows host; see https://bitbucket.org/dmenne/rstudio-shiny-server-on-ubuntu for details. This allows users to run RStudio and Shiny server on Windows. In Vagrantfile, I have

config.vm.synced_folder "shiny-server", "/srv/shiny-server", create:true

to create a shared folder. When I start the VM with vagrant up or vagrant reload, everything works ok.

One customer does not want to install vagrant etc, and asks for a standalone VM to be started/stopped with the VirtualBox Manager on Windows. However, after I shutdown a enter image description herevagrant-booted VM Box, my synced folders do not connect/mount again on VM restart, even if they turn up correctly in the shared folders dialog of the VirtualBox Manager.

How can I shrink-wrap a Vagrant-generated VM so it can be started/stopped without Vagrant?

EDIT March 2015:

I still could not resolve this. When I force automount, on restore media/sf_<folder> is synced, not the required folder. How can I force VirtualBox to use sync-template from Vagrantfile after a restart?

And how do I force automount in vagrant without doing it manually.

Best Answer

After some further debugging and the lack of response to a similar query on the google/vagrant forum:

  • When you use synced folders in puppet, you must restart VirtualBox with vagrant up or vagrant reload
  • If you use the VirtualBox GUI to stop/restart, automount restores the synced folders incorrectly, i.e. to /media/sf_; this cannot be corrected without using a vagrant reload,
  • The only alternative without vagrant is to save the state in VirtualBox (CTRL-V). After a restart, the synced folders are restored correctly. However, it is probably impossible to force end-users to always manually save the state.

To use persistent synced folders, you must use upstart or similar methods; it cannot be done with Vagrantfile only.

See also Alvaro's response: https://groups.google.com/forum/#!topic/vagrant-up/oBU0kqPLzYk

Related Topic