Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 20 down vote accepted

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

  • need to install Guest Additions in the guest OS
  • make sure users are in group vboxsf
  • define shared folders from the Virtual Box Manager

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:

enter image description here

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 prefix sf_ 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:

enter image description here

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.

share|improve this answer
That will make the guest OS to automount a host share, and I believe the OP wants the opposite: to mount a guest share in his host OS. If i'm wrong, than I completely misunderstood the question, and my answer should be ignored – MestreLion Jul 8 '11 at 21:52
@MestreLion: You are wrong, sorry! I think my problem is that I could never find the Shared drive on the Ubuntu VM because I had no idea it was mounting to /media. Had I realized that this question would not even have been necessary. – James P. Wright Jul 9 '11 at 3:35
@James: Oh, I'm sorry then. Mounting a host share in a guest OS is easy, and you have several options. Besides the (excellent, btw) answer given here, are you aware that a guest OS can be made seen in the LAN just like a regular machine? Just change network from the default NAT to Bridged. You can now "exchange" shares from guest to host (and vice-versa) using Nautilus, Samba, etc... – MestreLion Jul 9 '11 at 8:26
@MestreLion: to be honest - I mostly share my host (and guest) files by using Samba over the network ;) – Takkat Jul 9 '11 at 8:50
@Takkat: Me too! (and that makes both our answers obsolete! :P) – MestreLion Jul 9 '11 at 9:08

I don't think use of /etc/fstab will work (it didn't work for me) because that file is processed before the SF module is loaded and will fail to mount the share, see HOWTO: Use Shared Folders 1.

share|improve this answer
See for how to fix it. Basically, add the mount command in /etc/rc.local or equivalent. – Reinier Post Sep 15 '15 at 13:19

This is not a complete answer yet, but more like guidelines on 2 approaches you have:

1 - You could edit /etc/fstab and add this mount there. You would need to translate your mount parameter to fstab syntax. A wild guess would be something like /home/jamesw/host vboxsf myshare,umask=002,uid=<youruser>,gid=plugdev 0 0. You would need sudoto edit your fstab, but, once done, it will be auto-mounted on boot. Since this is done before you even log in, you need an absolute path to the mount point (hence /home/jamesw/host), you can not use $HOME or ~. Hint: "host" folder don't need to exist. If it is in fstab, mount will create it for you.

2 - You could use fusermount instead of mount. The syntax is similar (but not identical, so you still need to translate the mount parameters). Fusermount requires your mount point to be somewhere inside your $HOME, but the biggest advantage is that you would not need sudo. And the mount will be avaliable in Nautilus (as if it was a CD or USB key). After you get the right parameters and test it, you can add it to your ~/.profile, which runs every time you log in.

EDIT: Im assuming that either Virtualbox dont need the machine to be actually runing for it to share folders, OR that it is up and running before you log in

share|improve this answer
Using /etc/fstab doesn't work, see Kenneth Gulbrandsøy's answer. – Reinier Post Sep 15 '15 at 13:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.