How can I automatically mount vboxsf?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
markfilipak
Level 5
Level 5
Posts: 934
Joined: Sun Mar 10, 2013 8:08 pm
Location: Ohio (formerly California), USA

How can I automatically mount vboxsf?

Post by markfilipak »

This:

shared /home/mark/shared vboxsf defaults 0 0

inserted at the end of /etc/fstab (using gedit, as superuser), doesn't work.
But this command:

sudo mount -t vboxsf shared /home/mark/shared

from the command line does work, at least until I reboot Mint.

How can I automatically mount vboxsf?

Thanks - Mark.

altair4
Level 19
Level 19
Posts: 9903
Joined: Tue Feb 03, 2009 10:27 am

Re: How can I automatically mount vboxsf?

Post by altair4 »

Since the introduction of Version 4, VBox automatically mounts the host's shared directory for you without any action on your part.

If the guest OS is Linux it mounts to: /media/sf_XYZ

Where XYZ is the name you gave the shared folder in VBox. The only thing you may have to do is make sure you are a memebr of the vboxsf group in the Linux guest:

Code: Select all

sudo gpasswd -a altair vboxsf
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

sameucho
Level 1
Level 1
Posts: 20
Joined: Sun Feb 02, 2014 4:50 pm

Re: How can I automatically mount vboxsf?

Post by sameucho »

I have exactly the same problem: while logged-on, shared folder is shared & accessible after manualy executed command on guest (MINT) system:
sudo mount -t vboxsf -o uid=1000 VboxShared /home/myname/desktop/VboxShared/

Shared folder created on host (MINT too) system is /home/myname/desktop/VboxShared

Access righhts of /media/sf_VboxShared on guest system is 0770 and its content is the same as content of VboxShared on host system.

I also executed (to be sure): sudo gpasswd -a myname vboxsf

Everything is OK (even after loging off & on) until guest system is restarted. When logged on guest after restart again - VboxShared on guest is not shared with VboxShared on host until I execute mount command again! :(

Why?
Please help.

altair4
Level 19
Level 19
Posts: 9903
Joined: Tue Feb 03, 2009 10:27 am

Re: How can I automatically mount vboxsf?

Post by altair4 »

My guess is that you didn't tell the VBox application to automount the shared folder:
Auto-Mount.png
There is no need to manually mount anything or put anything in fstab.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

sameucho
Level 1
Level 1
Posts: 20
Joined: Sun Feb 02, 2014 4:50 pm

Re: How can I automatically mount vboxsf?

Post by sameucho »

No, you are not right. I of course checked also auto-mount option. Thats' why I am surprised why it don't work. BTW, my 'Shared folders settings' menu looks slightly different - there are three options to check - 'read-only', 'auto-mount' & 'permanent' + Folder Path & Folder Name (VirtualBox v. 4.3.6 r91406)

altair4
Level 19
Level 19
Posts: 9903
Joined: Tue Feb 03, 2009 10:27 am

Re: How can I automatically mount vboxsf?

Post by altair4 »

If you have auto-mount set and it's doesn't automatically mount the share to /media/sf_VboxShared with permissions such that you are allowed access I have no explanation. Sounds like a bug in VBox.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

sameucho
Level 1
Level 1
Posts: 20
Joined: Sun Feb 02, 2014 4:50 pm

Re: How can I automatically mount vboxsf?

Post by sameucho »

Would you know to give me any suggestion how to workaround this problem? E.g. by calling the "mount -t vboxsf ... " command (which works) during MINT's startup procedure? To put it so some rc.d or whatewer file? Or something else ...?

altair4
Level 19
Level 19
Posts: 9903
Joined: Tue Feb 03, 2009 10:27 am

Re: How can I automatically mount vboxsf?

Post by altair4 »

If you are mounting it this way:
sudo mount -t vboxsf -o uid=1000 VboxShared /home/myname/desktop/VboxShared/
Then the line at the end of /etc/fstab would look like this:

Code: Select all

VBoxShared /home/myname/desktop/VboxShared vboxsf defaults,uid=1000 0 0
You may or may not get an error though since your shared folder is already being mounted for you at /media/sf_VboxShared per your post:
sameucho wrote:Access righhts of /media/sf_VboxShared on guest system is 0770 and its content is the same as content of VboxShared on host system.
and you are in effect mounting it twice.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

sameucho
Level 1
Level 1
Posts: 20
Joined: Sun Feb 02, 2014 4:50 pm

Re: How can I automatically mount vboxsf?

Post by sameucho »

I have tried to update /etc/fstab file but it didn't help. Problem was, that during startup after reboot an error msg was displayed saying something like this: "Error: press S to skip ot M to correct mounting manually" (... or something like this, I don't remember exactly). Trying to skip, a word 'keys:' appeared on the screen, possibly startup sometimes hang up ... simillar to symptoms described here: http://forums.linuxmint.com/viewtopic.p ... ys#p817673

User avatar
grimdestripador
Level 6
Level 6
Posts: 1051
Joined: Fri Feb 16, 2007 2:26 am

Re: How can I automatically mount vboxsf?

Post by grimdestripador »

i had this same issue. I just made a script on the desktop which ran the mount commands.

altair4
Level 19
Level 19
Posts: 9903
Joined: Tue Feb 03, 2009 10:27 am

Re: How can I automatically mount vboxsf?

Post by altair4 »

sameucho wrote:I have tried to update /etc/fstab file but it didn't help. Problem was, that during startup after reboot an error msg was displayed saying something like this: "Error: press S to skip ot M to correct mounting manually" (... or something like this, I don't remember exactly). Trying to skip, a word 'keys:' appeared on the screen, possibly startup sometimes hang up ... simillar to symptoms described here: http://forums.linuxmint.com/viewtopic.p ... ys#p817673
Post the output of this command:

Code: Select all

cat /etc/fstab
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

sameucho
Level 1
Level 1
Posts: 20
Joined: Sun Feb 02, 2014 4:50 pm

Re: How can I automatically mount vboxsf?

Post by sameucho »

Thinking about it a little bit more I came to the conclusion it is not enough to set/check "Auto-mount" option in Shared folder's menu of Virtual box to have it mounted automatically. Indications are following:
- when adding a new shared folder via 'Shared folder' s menu, there is only possibility to select 'Folder path' which is path to host's (!) shared folded and to choose 'Folder name' which is name of shared folder in guest OS. But there is no possibility to specify mounting point of shared 'folder name' at guest side!
- when hovering mouse over shared folder menu, an info is displayed saying "List of all shared folders accessible to this machine. Use 'net use x: \\vboxsvr\share' to access a shared folder named share from a DOS-like OS, or 'mount -t vboxsf share mount_point' to access it from a Linux OS. This feature requires Guest Additions."

... why this info would be given if a pure auto-mount option would have been enough to get folders shared? And how auto-mount option would know where to mount shared folder in guest OS ?!

I am not expert in Linux and I am may be wrong, but I am in very doubts now that somebody have automount working just by checking an 'Auto-mount' option in Shared folders menu! :?
Any explanation pls?

But there is still opened my question (without answer so far) - how and where to add command 'sudo -u myName mount -t vboxsf -o uid=1000 sharedFolderName pathToMountPoint' (or something like this) to have the shared folder mounted at the end of OS startup? At least as workaround if my conclusions above are not correct. I think the file /etc/rc.local could be updated somehow (?). But there would be also necessary to config sudo , but I don't know how ... :(

Please give any suggestions.
Thanks

altair4
Level 19
Level 19
Posts: 9903
Joined: Tue Feb 03, 2009 10:27 am

Re: How can I automatically mount vboxsf?

Post by altair4 »

[1] Your shared folder is already automatically mounted per your own post:
sameucho wrote:Access righhts of /media/sf_VboxShared on guest system is 0770 and its content is the same as content of VboxShared on host system.
[2] If you want it to mount again automatically someplace else then put it in fstab on the guest which you said you already did:
I have tried to update /etc/fstab file but it didn't help. Problem was, that during startup after reboot an error msg was displayed saying something like this: "Error: press S to skip ot M
To which I suggested you post the output of the following command so we can see how you set it up:

Code: Select all

cat /etc/fstab
Why not post the output of this command as well:

Code: Select all

mount
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

tadaensylvermane
Level 2
Level 2
Posts: 79
Joined: Tue Jun 25, 2013 8:50 pm

Re: How can I automatically mount vboxsf?

Post by tadaensylvermane »

I am not expert in Linux and I am may be wrong, but I am in very doubts now that somebody have automount working just by checking an 'Auto-mount' option in Shared folders menu!
Been using automount for long time now. This sounds like you didn't do the guest additions properly to me. How did you install them if I may ask?
"List of all shared folders accessible to this machine. Use 'net use x: \\vboxsvr\share' to access a shared folder named share from a DOS-like OS, or 'mount -t vboxsf share mount_point' to access it from a Linux OS. This feature requires Guest Additions."
I'm real curious where you got this version of virtualbox because I can't find that dialog anywhere in mine, which is current from the virtualbox site.

For what it's worth if you want a work around it's just as easy to put a samba share on the host, put the guest on bridged network mode and do whatever through the network.

sameucho
Level 1
Level 1
Posts: 20
Joined: Sun Feb 02, 2014 4:50 pm

Re: How can I automatically mount vboxsf?

Post by sameucho »

I see I probably confuse terms with the impressions ... :?
OK, I will try to describe situation as exactly as possible:

First I installed 'Guest Additions" using commands:

Code: Select all

cd /media/myname/VBOXADDITIONS_4.3.6_91406 
sudo ./VBoxLinuxAdditions.run
BTW, tadaensylvermane, the 'Guest Additions' are integrated part of Virtual box for Linux 4.3.6. installation package which I have downloaded from here: https://www.virtualbox.org/wiki/Linux_Downloads

Next I added myname to vboxsf group by

Code: Select all

sudo -gpasswd -a myname vboxsf
In the 'shared folder settings' menu of virtual box I entered path to shared folder in host and foldername in guest (?) which was filled automatically based on previously given foldername. I also matched 'auto-mount' & 'permanent' option.

I think, after this all was done (and possibly after one or two restarts during this process) I could find the /media/sf_VboxShared folder containing the content of hosts' VboxShared folder (main.txt file):

Image

If this is effect of 'auto-mount' option from 'shared folder settings' menu, then OK, automount of shared folder works. Only at the begining of my experiments I had no idea I should look for shared folder located in /media/sf_VboxShared ... :?

As mentioned in my previous post, the 'shared folder settings' menu shows the hint to use mount comand to mount shared folder :

Image

So I tried to do so. After I executed command

Code: Select all

sudo mount -t vboxsf VboxShared /home/myname/Desktop/VboxShared/
, I could see in the content
od host's shared folder (file main.txt) in the guest's folder /home/myname/Desktop/VboxShared/ which is I want to have:

Image

After command

Code: Select all

sudo umount /home/myname/Desktop/VboxShared/
, the host's folder content was set to unavailable:

Image

Problem is that the shared folder mounted using

Code: Select all

sudo mount ...
command do not survive system reboot. After reboot it must be mounted again. So I tried to use 'automount' via /etc/fstab file ... :

Image

Image

See on the two screenshots above, that as soon as I put (and saved) to the /etc/fstab file line

Code: Select all

VboxShared /home/myname/Desktop/VboxShared vboxsf defaults,uid=1000 0 0
, VbosShared DEVICE appeared immediately in the file manager! But why device and not folder?

I would accept to have host's VboxShared folder available in guest also as a device (maybe only file manager present it as a sevice ?), but problem was that after system was rebooted, problem with mounting was reported during startup:
An error occured while mounting /home/myname/Desktop/VboxShared
Keys: Press S to Skip mounting or M for manual recovery
... I don't unerstand why ...

I hope now somebody will be able to tell me what I am doing wrong and what should I do to have VboxShared folder mounted to desired directory (/home/myname/Desktop/VboxShared/) and have it available also after system reboot. :?:

altair4
Level 19
Level 19
Posts: 9903
Joined: Tue Feb 03, 2009 10:27 am

Re: How can I automatically mount vboxsf?

Post by altair4 »

Then you don't want to mount it twice - you want is a symbolic link from the real mount point to your desktop:

Code: Select all

ln -s /media/sf_VboxShared $HOME/Desktop
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

streeeeetch
Level 1
Level 1
Posts: 1
Joined: Sat Feb 08, 2014 9:10 pm

Re: How can I automatically mount vboxsf?

Post by streeeeetch »

In case this is any use to anyone, a noobs experience with shared folders... Hope this helps someone

I'm a Linux noob but an experienced Windows user and support it for my work. I've just about had enough of Windows for my home machine (my work machine is not an option!) and decided to go Linux. My aim is to load Linux up in a VM, share my data folder and see if I can do everything I need to do for a few months before taking the plunge and installing it fully. I don't play games, just mainly need net access and managing my photo's and video and a little office work.
To that end I spent many quite frustrating hours trying to get the shared folders working and in the process read several forums and so far learnt quite a bit about the Linux command line - very useful. I'd recommend the very readable "The Linux Command Line" by William E Shots Jnr. You should find it floating around as a pdf, but there's plenty of free references and even Android terminal emulators to practice on.

This is for Windows host/ Linux guest
It's probably best if you start off with a new VM install (doesn't matter what happens then!). I've checked this with several Linux guests on both 32 and 64bit Windows hosts. It should be noted that I couldn't even install the additions on some distros but that's probably down to my severe lack of Linux knowledge though I'm working on it.

I humbly offer the following in the hope it might save someone many hours of trawling forums and pulling hair. This method worked for me and worked for my target distro - Mint.

Note don't type the quotes below...
Open Virtualbox but not your VM
In Virtualbox, click the VM then click Settings > Shared Folders
Ensure there are NO Folders shared
Do not share any folders yet - most important or the next steps will fail
Start the VM
Once fully booted, click Devices > Insert Guest Additions CD image
Depending on the distro it might pop up in a window or you might be given choices about where you want to see them. Doesn't matter what you choose as long as you can see the files
Open a terminal window
In the terminal wondows Type "cd /media/VBOXADDITIONS_......." (the dots represent the version number). This works just like the windows cd command. To save typing it all out you can drag the folder from whatever file manager is present into the terminal window and then edit the command line to read the above before pressing enter.
Next you need to execute the "VBoxLinuxAdditions.run" file but this needs to be done as root. Drag the file into the terminal window then edit the line to read "sudo sh VBoxLinuxAdditions.run" or just type it.
Press enter and then enter your root password when prompted
A warning should appear and ask you if you wish to continue. Answer "yes" (not "y"). This is good - it means it probably worked.
Let it finish installing. Look carefully at the output. If you see the word "fail" anywhere, it didn't work.
Close the VM
Providing it worked, click the VM and open settings > Shared Folders, click "machine folders" and add the folder(s) you wish to share. I've only tested this with one folder. Sub-folders automatically appear.
Set "Make permanent" and click ok.
Start the VM - your shared folder will be in /media

Bottom line is (as many of the forum contributors found) the additions supplied with the distro don't work and need to be overwritten with the virtualbox versions.

Please note that as stated I'm a noob at all of this so all you experienced peeps out there please forgive the mistakes etc. I read a load of forums and often they went into some detail about uninstalling the additions supplied with the distros but in my copious experimenting just overwriting them with the above method seems to work. I am aware that I might find I've stored up trouble for later but I guess that's all part of the fun!
As a footnote during the experimentation I've kind of settled on Mint KDE for starters but I can see this is going to be a bit of a journey.

sameucho
Level 1
Level 1
Posts: 20
Joined: Sun Feb 02, 2014 4:50 pm

[SOLVED] Re: How can I automatically mount vboxsf?

Post by sameucho »

altair4 wrote:Then you don't want to mount it twice - you want is a symbolic link from the real mount point to your desktop:

Code: Select all

ln -s /media/sf_VboxShared $HOME/Desktop
Thanks altair4, this hint works as expected.

Post Reply

Return to “Newbie Questions”