Change mount point of virtualbox shared folder
Solution 1
You have to change the "Guest properties" to modify the mount prefix and base directory used for the shared folders.
See https://www.virtualbox.org/manual/ch04.html#sf_mount_auto
and https://www.virtualbox.org/manual/ch04.html#guestadd-guestprops
An important note, though:
Both properties detailed in the first link have default values when not set or cleared:
/VirtualBox/GuestAdd/SharedFolders/MountPrefix
defaults to sf_
if not set.
Set /VirtualBox/GuestAdd/SharedFolders/MountDir
defaults to /media
if not set
As a consequence, you have to set MountPrefix
to /
if you do not want the sf_
prefix, as trying to set it to "" will in fact clear the property and put it back to its default value.
Solution 2
Check /etc/fstab
? I'm not too sure how virtualbox shares, so if changing the mount point breaks the sharing, you could change it back & bind mount /media/sf_share
to /srv
Info on bind mounting & fstab:
https://serverfault.com/questions/613179/how-do-i-do-mount-bind-in-etc-fstab
If I had a volume mounted at /media/3tb-vol1/Private/, and I wanted to bind it to /srv/Private I have a /etc/fstab like this.
/media/3tb-vol1/Private/ /srv/Private none bind
Of course, I don't know the details of VirtualBox's sharing. I'm not sure how & when /media/sf_share
gets mounted, if it's not ready when fstab
is, it might not be mounted in time to be bound...?
Solution 3
Based on Nawak's answer, I finally managed to get it done. I had already tried so many solutions (based on /etc/fstab/
and setting some /etc/rc.local
) but this one was the one that worked.
I just ran the following commands (from the host machine):
VBoxManage guestproperty set "Ubuntu 16" /VirtualBox/GuestAdd/SharedFolders/MountPrefix /
VBoxManage guestproperty set "Ubuntu 16" /VirtualBox/GuestAdd/SharedFolders/MountDir srv
Where Ubuntu 16
is the name of my VM. In order to check that these properyies where applied properly, you can run:
VBoxManage guestproperty enumerate "Ubuntu 16"
Related videos on Youtube
Comments
-
smilebomb over 1 year
I have a shared folder set up between virtualbox and my windows 7 host machine. I have a test.txt file that I created in Windows and it shows up appropriately in my Ubuntu VM. Virtualbox mounts the shared folder in
/media/sf_share
(the name I gave to the shared folder in the virtualbox settings wasshare
). I want to move the mount point from/media/sf_share
to simply/srv
so that on my windows host I can edit files and they show up under/srv
. How can I accomplish this?**
What I've tried:
**
I've edited
/etc/fstab
to look like this:share /srv vboxsf defaults 0 0
After doing this I used the command
mount -a
, also I rebooted, and I rebooted again with the virtualbox shared folder settings to NOT auto-mount.I read there is an issue with filesystems being mounted before virtualbox utilities are loaded, so I added
vboxsf
to my/etc/modules
and then repeated the steps above.None of them reproduce the correct content in /
srv
. When I issuemount -a
AFTER I have edited thefstab
I can sometimes get it to work. I don't know what I'm doing differently each time, but sometimes after I editfstab
, issuemount -a
without rebooting I can see the files there. After a reboot though the files are gone again.-
Takkat over 9 yearspossible duplicate of How to mount a VirtualBox shared folder at startup?
-
-
smilebomb over 9 yearsAnd what would I be looking for in fstab?
-
Xen2050 over 9 years
/media/sf_share
, that's what you want to change right? -
smilebomb over 9 yearsThat does not appear is
fstab
. I triedmount --bind /media/sf_share /srv
and that appears to be working. -
smilebomb over 9 yearsWell, after a reboot all the contents were lost from
/srv
-
Xen2050 over 9 yearsa terminal
mount
would only be in effect until a reboot. Maybe add it to/etc/fstab
if it exists at bootup, or to a login script or a one-liner script file (to run when needed) if it's not there until later -
smilebomb over 9 yearsI tried adding it and it didn't work: inside fstab
/media/sf_share /srv auto bind 0 0
no luck -
smilebomb over 9 yearsPlease see the edit to my question.
-
Mahn almost 8 yearsI was going crazy trying to figure out how to set
MountPrefix
to an empty value, setting it to/
did the trick, thanks!