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 vagrant-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.
After some further debugging and the lack of response to a similar query on the google/vagrant forum:
vagrant up
or vagrant reload
vagrant reload
,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
There are two parts to getting this to work. First, we need to get the synced folders automatically mounting from the host, which is the case of a Linux guest is a bit of a misnomer, because it's more "being automatically made available for mounting", or "automatically shared". For each shared folder (gemainsame ordner) you must turn on auto mount (automatische einbinden)
To do this, click on the edit shared folder icon for each share
And check auto mount (automatische einbinden)
At the end you should see "Ja" under "automatische Einbinden" for all the shares to should auto-sync
If the guest system is Ubuntu (or any Linux system), then having done this, all the synced folders should now be visible within to the guest, but the guest won't automatically mount them. You will need to put an entry into your /etc/fstab for each folder you want automatically mounted in the guest.
Since you are using VirtualBox, Vagrant will presumably choose to implement the synced folders using VirutalBox's shared folder provisioning method. To the guest system in Linux, depending on your version of Guest Additions, this looks like either an smb/cifs share with the name (by default) of //vboxsrv/, or a file system of type "vboxsf".
The vboxsf is from more recent version of guest additions (4.1.18 onwards at least), and automount option 'just works'. On booting a Linux guest VM with an automount set share called 'bob', the system should mount Bob automatically (without an fstab entry) at /media/sf_Bob
. The full output of the relevant line from mount
is
none on media/sf_Bob type vboxsf (rw,nodev,relatime)
If this isn't working, check that you can see a samba network share from within your guest system, using smbclient or smbtree. It should look like //vboxsrv/Bob
. In your fstab then, you would add a line like this
#share name #mount point in guest #fstype #options #dump/pass
//vboxsrv/Bob /mnt/Bob cifs auto,rw 0 0
You may wish to read the manual page for mount.cifs
to tune the options for each mount, especially with regards to file ownership and permissions (relevant options to investigate are forceuid
, uid
, forcegid
, gid
, file_mode
, and dir_mode
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With