Page 1 of 1
Mount programatically shared folder
Posted: 23. Mar 2016, 22:50
by Winxp-on-Macos
A script shout mount shared folder provided by host, as described in V.B. manual chapter 4.3.1
to free the user from this job. Sure, user will need to call the script, however script call's syntax will be
more straightforward than that one of mount command.
Is it possible for guest script to ask the environment or the guest OS for current value of mount-point prefix,
as that one to be tested by /VirtualBox/GuestAdd/SharedFolders/MountPrefix on host side (see sf_) ?
Is it possible for guest script to ask the environment or the guest OS for current value of mount directory
as that one to be tested by /VirtualBox/GuestAdd/SharedFolders/MountDir on host side (see /media) ?
Is it possible for guest script to ask the environment or the guest OS for current name
of users group to be used for shared folder guest accesses (see vboxsf)?
Just in opposite, no way for guest script than to have all those fix-coded?
Re: Mount programatically shared folder
Posted: 23. Mar 2016, 23:27
by Perryg
Auto mounting shared folders is described here:
viewtopic.php?f=29&t=15868 and I believe I sent this link to you already. Point in fact, the guest is doing the mounting. If your guest does not have /etc/rc.local then you should ask the guest OS forum how they want you to mount devices at boot.
Re: Mount programatically shared folder
Posted: 23. Mar 2016, 23:41
by Winxp-on-Macos
In this env. shared folder must not mount on boot.
It has to mount only on user inter-action.
However, as soon as such shared folder attachment initiating inter-action in progress,
it has to be as simple as possible. Invoke the mount sequence by user from shell is not acceptable
as many mount options have to be entered in order to get results satisfying for user requirement
(those are, share folder working w/o guest restart, shared folder non-permanent,
attach shared folder while guest machine is operating).
Shared folder must not be permanent, only transient are allowed.
Mentioned 3 parameters (mount-point name prefix, mount-point directory, users group
with access to V.B. shared folders enabled by default) are V.B. -specific topics.
Re: Mount programatically shared folder
Posted: 23. Mar 2016, 23:47
by Perryg
Very well but this still has nothing to do with VirtualBox. Mounts are part of the guests operating system. I write scripts to do this but you must do so with elevated permission because that is the way it works for security reasons.
Re: Mount programatically shared folder
Posted: 24. Mar 2016, 00:00
by Winxp-on-Macos
OK. Do you really mean it is Ubuntu's or its designers decision to
-) use "sf_" prefix for V.B. shared folder mount-points
-) use /media as folder directory for V.B. shared folder mount points
-) to create and use the user group called vboxsf with built-in privileges to access V.B. shared folders ?
Please take into your account only these questions/points are addressed in this thread.
Not other topics nor problems.
If it really works the way as pointed out above there is a risk that prefix, parent directory and user group
change with switching to other Linux distribution. Is it not strange?
Re: Mount programatically shared folder
Posted: 24. Mar 2016, 00:05
by Martin
Why don't you just disable the automount feature and mount the folder how and where you like with a simple script (which would work the same way on all Linux variants: mount -t vboxsf...)?
Re: Mount programatically shared folder
Posted: 24. Mar 2016, 00:11
by Winxp-on-Macos
That's even and exact what I am doing. It was never and no one time said auto-mount is used or going to be used.
Sorry, I mean here the auto-mount provided by V.B., the v.m. settings.
Simplifying the mounting on guest side by adding entries to /etc/fstab does not satisfy because
there is a large number of folders provided by host for sharing.
Re: Mount programatically shared folder
Posted: 24. Mar 2016, 00:35
by Perryg
-) use "sf_" prefix for V.B. shared folder mount-points
-) use /media as folder directory for V.B. shared folder mount points
-) to create and use the user group called vboxsf with built-in privileges to access V.B. shared folders ?
The only way you can have the conditions you listed are when using automatic shared folder. What Martin said is correct in that you should not use it if you want to control anything with the way it works. I will also say that it would not matter if you used a CIFS share or any type of network share. You would need to mount them the same way no matter how many there were. You can write scripts to do this but it is still controlled by the guest OS and not VirtualBox.
Re: Mount programatically shared folder
Posted: 24. Mar 2016, 01:03
by Winxp-on-Macos
Well. Thanks.
My script replaces V.B. auto-mount because the latter one does not deliver satisfying behaviour
(shared folder working not until guest restart).
My script seeks also to follow conventions used by V.B. auto-mount option if it comes to user experience.
Means: sf_ prefix, and /media parent dir. Otherwise irritation arises on user-side when she or he has
to look for shared folder at unusual (from V.B. user's perspective) place.
Reg. 3rd param:
To circumvent the vboxsf user group will be costly in programming efforts and not reasonable.
I still do not see the answer, does the script really have to fix-code "sf_" and "/media"
or any chance to get these strings/values from working environment, OS or any other settings storage?
The goal is to achieve script's portability as far as possible.
Means if some days V.B. programmers decide to change the auto-mount conventions
from sf_ prefix and/or /media parent to any other choices the script adapts to these changes by itself.
My subjective impression is, the sf_ prefix and /media parent folder is some kind of
convention met by V.B. for shared folders. Any chance for script running on guest to detect this convention
without shared folders to be attached. Please not it will be only that script what attaches shared folder to v.m.,
nobody nor nothing else.
Re: Mount programatically shared folder
Posted: 24. Mar 2016, 01:23
by Perryg
I still do not see the answer, does the script really have to fix-code "sf_" and "/media"
No! This is the side effect of using the automatic shared folder. Necessary only if you are using the automatic shared folder.
For instance I use /mnt and do not add user to vboxsf group. I write scripts that do what I want and use standard Linux mounting procedure. I add options to the mount to allow various activities like read write or execute, and allow the user UID and GID in the options so I have better control of the share.
Re: Mount programatically shared folder
Posted: 24. Mar 2016, 20:50
by Winxp-on-Macos
Thanks, I got it.
In this case user migrates from V.B. shared folders auto-mounted (auto-mount driven by adequate option in V.B. shared folders dialog)
to shared folders of same kind however mounted by script running on guest. So the user is used to look
for V.B. shared folders under /media and is looking for directories whose name starts with sf_.
Regarding mount-points of external storage of any kind there are not other habits on user side.
Script must not break with user's habits.
There must be some kind of V.B. agent running on guest side (VirtualBox service (?))
which receives the information from V.B. user had selected in shared folders dialog the auto-mount option.
I wonder if it is possible for script to eavesdrop this communication, as inside possibly the information
regarding prefix and mount parent are included. Script could than detect the prefix and parent at run-time
and does not need to fix-code them , thus better portability.
The problem however is, user migrates fro auto-mount to script driven mount, that means user
will never activate the auto-mount option in shared folders window, so even if my assumption is right
there is no chance to eavesdrop the needed information.