Mounting a shared folder automatically to a certain dir

Discussions related to using VirtualBox on Windows hosts.
Post Reply
DR
Posts: 4
Joined: 5. Mar 2015, 19:41

Mounting a shared folder automatically to a certain dir

Post by DR »

I am trying to mount a shared folder automatically in a guest Ubuntu 14.04 from a host Win 7 64bit. Using VB 4.3.16.

(I am new to Linux!)

The folder I am trying to mount is

Code: Select all

/var/www/html
folder which is apache’s public folder.

I have a folder at

Code: Select all

C:\html
that I have prepared for it and mapped as a shared folder in the Virtual Box Manager. I have it set to auto-mount, and to make it permanent.

I use the command:

Code: Select all

sudo mount -t vboxsf html /var/www/html
And it works. Until the next reboot when the mapping is lost and I have to run the command again.

I found out it is still mapped at

Code: Select all

/media/sf_html
through googling.

How can I make it auto share or auto mount my /var/www/html folder with C:\html automatically, or at the guest's startup?
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: just about all that run

Re: Mounting a shared folder automatically to a certain dir

Post by loukingjr »

you don't need to use a command with an auto-mounting shared folder.
DR wrote:I am trying to mount a shared folder automatically in a guest Ubuntu 14.04 from a host Win 7 64bit. Using VB 4.3.16.
I found out it is still mapped at

Code: Select all

/media/sf_html
.
that's because /media/sf_* is where shared folders are automatically mounted in most Linux guests. If that's not a convenient location you can bookmark it to show up in the side pane of the file manager.

if you want to mount it at another location you would have to disable auto-mount and mount is manually.
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
DR
Posts: 4
Joined: 5. Mar 2015, 19:41

Re: Mounting a shared folder automatically to a certain dir

Post by DR »

The sf_folders are actually not convenient for me, as some of the folders I want to mount are files containing configuration files (for programs like apache) that I would like to be able to edit in windows. So bookmarking it to the file manager would not help in this case, either.
I am new, so I was probably not clear, but I see that vbox lets you mount to any previously specified shared folder from within the guest using a command, but it apparently won't let you keep that mounting after a reboot?

I did some more searching and found this post:
stackoverflow / a / 22342140 (on stack over flow) (I couldn't post the address because I am under one day old here.)

It seems to be what I want, but due to my (very) limited knowledge I do not understand how to implement this. If this is correct, could you provide example steps so that I can automatically mount

Code: Select all

/var/www/html 
to

Code: Select all

c:\html
and have it remain that way after a reboot?
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: just about all that run

Re: Mounting a shared folder automatically to a certain dir

Post by loukingjr »

See: My next post.
Last edited by loukingjr on 6. Mar 2015, 00:52, edited 1 time in total.
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Mounting a shared folder automatically to a certain dir

Post by Perryg »

To make a Linux mount permanent you need to add the statement to the /etc/rc.local file if it exists and if not to the /etc/fstab.

Be very careful when working with the fstab though as a mistake can keep your os from booting.
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: just about all that run

Re: Mounting a shared folder automatically to a certain dir

Post by loukingjr »

See: Howto: Shared Folders

I was just about to delete my previous post. :)
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
DR
Posts: 4
Joined: 5. Mar 2015, 19:41

Re: Mounting a shared folder automatically to a certain dir

Post by DR »

I added:

Code: Select all

html /var/www/html/ vboxsf defaults 0 0
and it told me that it could not boot /var/www/html when booting the machine, and asked me to skip it or manually recover it.

So I added it the mount command I used above to rc.local (without a sudo):

Code: Select all

mount -t vboxsf html /var/www/html
and it seems to have worked. Thank you!

If there are any other concerns here (remember I am new!) I'd be glad to hear them. I am not sure why the fstab addition did not work, though, it followed the help doc guide loukingjr linked to exactly (I think).

Edit: Read the new link posted and saw that fstab occurs too early, so that is why there is an error.
Post Reply