I have a Ubuntu VM running in VirtualBox.
I have a Shared Folder set up as myshare
I have a folder created in my home directory (~/jamesw
) as host
.
using the line sudo mount -t vboxsf myshare host
from my home directory in Terminal mounts the drive correctly, but if I reboot it is not mounted again.
This is a VM I use for running a simple web server and I would like this Share mounted each time I boot.
Is there any way to do this? Especially given that it requires sudo?
Best Answer
Auto-mount shared folders using Virtual Box Manager
From Virtual Box > 4.0 we are able to auto mount shared folders in a virtual machine. To do so for Ubuntu we
vboxsf
Right click on your virtual machine and choose Settings->Shared Folders. This will list existing shares or lets you define a new shared folde by clicking on the blue folder icon with the green +-sign on the top right side:
Choose your folder from the dropdown menu Folder path or choose Define other for a file selector that lists the host filesystem. Choose a name for the share (e.g. myshares). By ticking Auto-mount this folder will always be mounted in the Ubuntu guest directory
/media/sf_myshares
(the prefixsf_
will automatically be added).Alternatively, to define shared folders in a running guest OS we may select Devices -> Shared Folders from the window menu of Virtual Box Manager:
By ticking Make Permanent these shared folders will also be available on the next boot and will be mounted when Auto-mount is ticked in addition.