Shared folder disappear after virtual machine shutdown

I'm running Ubuntu 14.04 on VirtualBox 5.0.24 r108355.

I mount my folder with command:

mkdir my_folder
sudo mount -t vboxsf my_folder /home/user/my_folder

In VirtualBox settings (Devices->Shared fodlers->Shared folders settings) I have Auto-mount and Make Permanent folders checked.

When I close and reopen my VM shared folder is not mounted and I need to perform sudo mount -t vboxsf my_folder /home/user/my_folder once more time.

So how to make shared folder mounting permanent?


Solution 1:

Shared folder auto mounting chooses an "auto" mount point; it will not miraculously use some particular mount point you yourself used at some particular moment.

The VirtualBox Guest Additions auto mount point for Linux is composed of a prefix, /media/sf_ by default, prepended to the name under which you share the folder in VirtualBox. You can change the prefix to /home/user/ with a VboxManage command:

 VBoxManage guestproperty set <vm> /VirtualBox/GuestAdd/SharedFolders/MountPrefix /home/user/

where is the name or UUID of your virtual machine. Because a virtual machine only has a single such prefix, it would apply to all auto-mounted shared folders of that virtual machine.