LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 02-17-2016, 10:59 PM   #1
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Am I missing something? Mounting VirtualBox shares


It seems that the only reliable way for me to mount a share in VirtualBox is to specify this in the external user-interface. But, if I do that, the share is always mounted as root/vboxsf.

I need to specify that I want the share to be mounted as someone else and to have a "755" security mask.

Attempting to do this in, say, /etc/rc.local are unsuccessful apparently due to timing problems.

I've put an entry in /etc/fstab although it is not "auto."

How does the mechanism in the VirtualBox user-interface actually work? It seems to be the only way to reliably mount the share at startup, but it seems to give me no control.
 
Old 02-18-2016, 05:46 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,289

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
I set up two shares at the top level when setting up the vm

1. /home/my_luser/Electronics
2. /mnt

On Slackware, the second one was sly, because usb sticks and my sdcard reader are mounted under /mnt in /etc/fstab. Both appear in Vista as separate drives.Only new automounts in X go under /run/media.
 
Old 02-18-2016, 06:00 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659

Original Poster
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Irrespective of where the shares mount, the problem seems to be ensuring that they are mounted at the time that a particular service -- Apache2 -- needs to use them. [i](This is an eleven-year old application that is finally getting a makeover. Think, "two gigabytes of RewriteMaps." And yet, it completes thousands of dollars' worth of business every day and hosts more than 150 sites.)

If I let VBox do it ... and I don't know how it does it, yet ... the shares appear to be there (or maybe they aren't yet). If I mount them in /etc/rc.local, they don't actually mount at boot, although the same script, if issued afterwards, works. (So, the commands are correct but the timing is wrong.)

I think(!) that "I would be a very happy boy, if ..." I could actually specify how VBox mounts those shares (itself), and it stands to reason that I should, if only I better understood how their mechanism works!

I've read many posts, some tantalizingly marked as [SOLVED], but I need to proceed with great caution here so that I don't accidentally "brick" the VM. Some folks have suggested, for instance, "put the vboxsf module into /etc/modules so that it loads very early." Well, that could very easily be a "brick" if it doesn't work. I'd be scro-o-o-ood for a good, long time that I don't have.

Since system-start is "a very asynchronous time," I'm not sure that trying to put the Apache process into the vboxsf group would even work, assuming I could figure out how to do it, if it actually is a timing issue.

This topic at virtualbox.org, e.g., specifically speaks of timing issues in its last comment:
Quote:
Tf you want to have it mount automatically upon each boot, put the mount command in /etc/rc.local (Debian based distro's), or whatever script is run at the end of the boot process. The Shared Folders service should mount them automatically, but that doesn't always happen.

Using /etc/fstab has little effect, because that file is processed before the SF module is loaded and will fail to mount the share. Sometimes, the share does get mounted because the GA ["what's GA ??"] check for it when they are loaded upon boot, but it's very flaky, meaning it doesn't work most of the time. You're better of with the first option.
Words like "very flaky" or "doesn't always happen" do not make me feel comfy.

I could arrange things to circumvent startup timing problems if I could control the permissions and/or the ownership of the shares! There must be some Linux-side code in play here ... but, where did Oracle Corporation put it?

This topic seems very detailed and complete, but it was written in 2007 or so, and has the caveat that others said it didn't work anymore. And, again, I really don't want to stray too far into hacker-land on this.

Last edited by sundialsvcs; 02-18-2016 at 06:28 AM.
 
Old 02-18-2016, 06:31 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659

Original Poster
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Okay, I'm gonna mark this thread as [SOLVED] with the following simple recommendation:
  1. If you want shares mounted, specify the shares in the VirtualBox user interface. They will (somehow ...) be mounted (by VirtualBox 5.0.14 for OS/X) in time for startup services such as Apache to access them.
  2. To make it possible for Apache to do this, first observe what user-id Apache runs its daemons in (as defined in the Apache configuration file, or by a simple peek at ps -A outuput ...), and add this user-id to the vboxsf group.
For instance:
groups www_user ... (to see what the group-list now is)
usermod www_user -a -G vboxsf ... (to add the group-id to this user)
groups www_user ... (to see if it worked!)
  • Do not forget the -a parameter, since you want to add to, rather than replace, the user's groups-list.)
(Or use your favorite GUI tool if you're a "weenie ..." )

Seriously... "it works, and it seems to work quite reliably."

Note(!) that you do not have to worry about the Group directive in the Apache configuration file! It doesn't matter "which gid = group_id the Apache daemons run under while they are executing." What matters is the "list of groups that this user (the User directive ...) belongs to."

Obviously, this uid should not be nobody, but Apache (for obvious reasons related to "real" file-access) doesn't use that user-id anyway. Add the daemon-userid to the group, and everything else seems to come out in the wash.

In light of this, it now seems someone's very-deliberate choice that the permissions-mask for the share is rwxrwx--- root vboxsf ... which seems to be pointing very-directly to "group membership" as being the only way, by design, to specify who is to have access to the share and who is not.

Yeah, sure, probably "a very well thought-out solution." Gee ... they could have "written a few paragraphs to that effect ... mmm?"

Last edited by sundialsvcs; 02-18-2016 at 06:41 PM.
 
1 members found this post helpful.
Old 02-22-2017, 11:00 PM   #5
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
I've been trying to solve this problem for two days now and just found this post, but I don't fully understand your solution (which I'm grateful for, btw).

questions:

1) what do you mean by 'specify the shares in the VirtualBox user interface?' I'm guessing you mean the Add Share dialog that you can access from the Settings->shared folders dialog? I.e., the place where you browse the host system to select a folder to be shared? Unless I'm mistaken, this has nothing to do with mounting but just identifies/defines shared folders apache migh want to read on the host system?
2) Not sure either what you mean by "observe what user-id Apache runs its daemons in (as defined in the Apache configuration file, or by a simple peek at ps -A outuput ...)" ? What do you mean by its daemons? Apache appears to run as www-data on the Ubuntu machines I'm working with. Do you mean the userid for user www-data? Or a group id for group www-data? Something else? When I execute ps -A, I see a handful of apache2 instances, but no instances of www-data. On the other hand, /etc/passwd and /etc/group do not contain the word 'apache' in them anywhere. I had already added user www-data to the vboxsf group when concocting my mount command.

I've tried adding a mount command to /etc/fstab to mount the shared folder at startup with no joy. This is the current directive. It doesn't block the boot process like others have, but neither does it actually result in the drive getting mounted:
Code:
# added by jta 2017-02-22 to mount oddballs shared folder from host
#my-share /var/www/my-dir    vboxsf   rw,noauto   0     1
I've no idea where to look for any errors caused by this directive. Once the machine boots, I try listing /var/www/my-dir and rather than the contents of the share, it's just the empty folder.

Any help would be much appreciated.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mounting shares on boot aslanprrrrrrr Linux - Networking 1 01-16-2008 10:24 AM
mounting samba shares wheaties_box Linux - Software 1 01-23-2007 12:21 AM
mounting shares with samba darkleaf Linux - Software 1 02-13-2005 06:13 AM
Mounting Windows Shares ilumin8d Linux - Networking 4 07-15-2003 02:36 AM
Mounting Windows Shares Thermos Linux - Networking 3 07-09-2003 01:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 03:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration