auto-mounting shared folders in VirtualBox
I am writing to ask what the effect of the auto-mounting process is in VirtualBox, and where the folders can be accessed within a guest Linux system if auto-mount is used.
I have VirtualBox 4.0.4 installed on Mac OS 10.6.7, with Guest Additions apparently running correctly. The guest OS is Ubuntu 10.04, and I observe no apparent problems with it. I find that if the shared folders have "auto-mount" unchecked in the VirtualBox settings, they can then be mounted using the prescribed syntax
sudo mount -t vboxsf folder_name path_to_mount_point
and all works as it is supposed to.
But if the auto-mount option is checked, then I find that I can no longer mount the shared folders manually. I get the error
mounting failed with the error: Invalid argument
and the folders also do not appear to mount anywhere else accessible to me. Using the syntax
sudo mount -t vboxsf
without specifying a path installs them in /media, with their names prefixed with sf_
, but they are not easily accessible there and I have not been able to change their owner using chown
, either.
Thanks for your patient explanation.
I had similar problems and found that my fstab wasn't auto mounting for some reason, whether I had the Auto mount checked or not. So I tried this approach instead and it worked fine:
- Create a directory to mount into (if you haven't already):
mkdir -p /mnt/path_to_mount_point
- Edit your rc.local file:
nano /etc/rc.local
- Append the following line and save:
mount.vboxsf -w -o fmode=0777,dmode=0777 folder_name /mnt/path_to_mount_point
Reboot and it should mount with the correct permissions.
As described in here:
https://www.virtualbox.org/manual/ch04.html#sf_mount_auto
With Linux guests, auto-mounted shared folders are mounted into the /media directory, along with the prefix sf_. For example, the shared folder myfiles would be mounted to /media/sf_myfiles on Linux and /mnt/sf_myfiles on Solaris.
Then it's also said that:
Access to auto-mounted shared folders is only granted to the user group vboxsf, which is created by the VirtualBox Guest Additions installer. Hence guest users have to be member of that group to have read/write access or to have read-only access in case the folder is not mapped writable.
So, you have to add your user to the group vboxsf with this command:
gpasswd -a your_user_name vboxsf
or
usermod -a -G vboxsf your_user_name
Then verify it:
groups your_user_name
For file manager, it will not reflect the change immediately, you have to log-out and log-in again too see the change.
That is happening because you haven't indicated to your Guess OS that it has to mount that folder, you just told VirtualBox to share that folder. In order to auto mount a folder in Debian (it should be simillar for other Linux)
Edit as root the file /etc/fstab and at the bottom add the following line:
folder_name path_to_mount_point vboxsf defaults 0 0
The path_to_mount must exist
then just run:
sudo mount -a
or reboot your VM