Can't mount shared folder in Centos guest

Discussions about using Linux guests in VirtualBox.
ohaya
Posts: 59
Joined: 31. Dec 2012, 08:08

Can't mount shared folder in Centos guest

Post by ohaya »

Hi,

I am using VBox 4.3.6, on Windows 7 64 bit. I have a Centos guest. In the guest settings, I've created a permanent shared folder named "shared". This is using the G:\ directory on the Win7 machine.

In the guest, I've created a directory, /mnt/myoam. However, in the Centos guest, I cannot mount the shared folder.

Code: Select all

[root@oamoam log]# cd /mnt/
[root@oamoam mnt]# ls
myoam
[root@oamoam mnt]# mount -t vboxsf shared /mnt/myoam/
/sbin/mount.vboxsf: mounting failed with the error: Protocol error
[root@oamoam mnt]#
[root@oamoam mnt]#
[root@oamoam mnt]# mount.vboxsf shared /mnt/myoam/
mount.vboxsf: mounting failed with the error: Protocol error
The VBox tools are definitely installed, and I've looked at the FAQ but can't get this working. Can anyone suggest anything else to get this working?

Thanks,
Jim
ohaya
Posts: 59
Joined: 31. Dec 2012, 08:08

Re: Can't mount shared folder in Centos guest

Post by ohaya »

Hi,

When I try the mount, I am seeing the following in dmesg:

Code: Select all

VbglR0HGCMInternalCall: vbglR0HGCMInternalPreprocessCall failed. rc=-2
VBoxGuestCommonIOCtl: HGCM_CALL: 64 Failed. rc=-2.
VbglR0HGCMInternalCall: vbglR0HGCMInternalPreprocessCall failed. rc=-2
VBoxGuestCommonIOCtl: HGCM_CALL: 64 Failed. rc=-2.
sf_read_super_aux err=-71
VbglR0HGCMInternalCall: vbglR0HGCMInternalPreprocessCall failed. rc=-2
VBoxGuestCommonIOCtl: HGCM_CALL: 64 Failed. rc=-2.
sf_read_super_aux err=-71
VbglR0HGCMInternalCall: vbglR0HGCMInternalPreprocessCall failed. rc=-2
VBoxGuestCommonIOCtl: HGCM_CALL: 64 Failed. rc=-2.
sf_read_super_aux err=-71
I found this old defect: https://www.virtualbox.org/ticket/928
but I tried changing the share name to "install" and still got the same problem???

Anyone?

Thanks,
Jim
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Can't mount shared folder in Centos guest

Post by Perryg »

And you are sure that the guest additions are installed in the guest?

Usually the only thing that produces protocol errors are missing guest additions of typos.
ohaya
Posts: 59
Joined: 31. Dec 2012, 08:08

Re: Can't mount shared folder in Centos guest

Post by ohaya »

I've re-installed the Guest additions multiple times, including running the installer manually as root. the vbadd-install.log doesn't seem to show any errors. There are bunches of warnings, but no errors I can find.

I also confirmed that there's a vboxsf group in /etc/group (found an old thread about that).

The guest is Centos, but it's kind of an older version, like 4.8. Could that be a problem?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Can't mount shared folder in Centos guest

Post by Perryg »

Anything is possible I guess. The only reason for the guest user to be in the vboxsf group is if you are using auto-mount.
ohaya
Posts: 59
Joined: 31. Dec 2012, 08:08

Re: Can't mount shared folder in Centos guest

Post by ohaya »

Hi,

I haven't made any headway with this... still not able to get shared folder working.

So, I've gone ahead and created and added a new drive on the guest as I need to move forward for now.

If anyone else has any ideas, please let me know.

Thanks,
Jim
CertifiedMuffDiver
Posts: 2
Joined: 14. Sep 2014, 10:49

Re: Can't mount shared folder in Centos guest

Post by CertifiedMuffDiver »

I think I found out the cure to our problems that all the other help articles and forums dont explain whats happening thats causing the /sbin/vboxsf protocol error.

What I found out is first in Windows, YOU DONT HAVE TO SHARE the folder you want to share.

Next, if you have already installed the Guest Additions CD like all the other directions from all the sites explain then you can keep moving on. First your Guest Cent OS server has to be shutdown or closed for this to work.
now go to the settings button in the top menu bar. Go down to Shared Folders tab in the left menu. Now you should see the menu tree and you should see Machine Folders only. (transient Folders only shows up while Servers are running) Next select the Add Folder Icon in the far right menu. You have to use this Shared Folder Tool for any sharing between Hosts and Guests to actually work. this Tool is like the Demarcation Point Box for you telephone on the outside of you house for a good analogy.

NOW here is where the major point you have to understand for this to work and I believe every ones mistake is happening. The pop up window has options for "Folder Path:" and then "Folder Name:". In Windows Host sharing, what ever folder path you add is now going to be hidden behind the name of the Folder Name as the Folder Name is now considered the SHARE NAME you dont have to use the actual folder path anymore after this point as the Folder Name has the information included with it. So if you change the Folder Name to something not the exact name of the actual folder, then you are actually changing the SHARE NAME. When you add the folder into the Folder path from what ever Harddrive letter location you choose, Virtualbox will automatically call the SHARE NAME the name of the folder you added, but you can still call the SHARE NAME what ever you want but you have to remember the SHARE NAME as that is the name you will use later on during the mounting procedure. Oracle could of actually made it less confusing to people if they just called the "Folder Name:" "Shared Name:". Now you have 3 options you can select: Read Only, Auto-mount, Make Permanent. If you are trying to manually learn how to mount shared folders with in Cent OS konsole then only select Make Permanent option. If you select Auto-mount too, Virtualbox actually does all the work for you and automatically mounts the folder to the default location of: (File System) /media/sf_<SHARE NAME> and YOU CANNOT mount an already mounted folder twice. You would actually then have to move the folder somewhere else instead and or change the folders name from sf_<SHARE NAME> to what you want after.

Ok, next after you have made the folder permanent and you select Ok you should now see under Machine Folder: SHARE NAME folder path Access Full.
Now you can start you CentOS Server. Now you can open up your Terminal or Konsole.

first in CentOS, for all the newbies like I was you cannot use the SUDO command like many directions show you. SUDO has to be configured manually through CentOS for it to work, and thats difficult to need to know right now. all you need to use is the SU command and Login into your ROOT password to start off.
example:
[user@localhost ~}$ su

[user@localhost ~}$
password: <typing your root password you created during install> then hitting Enter

[root@localhost user}#


Ok now that we have root superuser access we have to first create a new folder that we will be wanting to mount as the Demarcation Point between our Host and Guest. I am going to show you how to mount a folder into the default location to make things easier and for you to see it work to believe it works and then later on you can recreate the actions and then you can create the mounting point in what ever directory you would like or familiar with like most people seem to want to put it in the /mnt/ folder.

[root@localhost user}# mkdir /media/<SHARE NAME>
example:
[root@localhost user}# mkdir /media/share
[root@localhost user}#
[root@localhost user}# ls /media/
share


now that we created the folder the SHARE NAME we can now use the vboxsf command to create the demarcation point between the Host and Guest. this is where the confusion happens with everyone and also even the vboxsf command too. You dont have to use the Windows folder path at all in the vboxsf command like if you shared a folder not on your C:\ drive and on a different Harddrive. The Virtualbox Shared Folders Tool creates a Share Name that includes the Windows folder path in it hidden like I explained earlier. when using the mount -t vboxsf <share name> </path/foldername> command, in basic human language this reads like this:
I want to mount a device directory option -t using the virtualbox sharefolder command vboxsf to share my HOST SHARE NAME device to the location of the GUESTS new folder i created in my guest system directory. or simply:
mount -t vboxsf <HOST SHARE NAME> </GUEST path/new folders name>

[root@localhost user}# mount -t vboxsf <SHARE NAME> /media/<SHARE NAME>
[root@localhost user}#
example:
[root@localhost user}# mount -t vboxsf share /media/share
[root@localhost user}#


if you follow me directly you should not get a /sbin/vboxsf protocol:error again and like my example shows it succeeded and went back to the root entry as if something actually worked.

now some people have been explaining problems with it /sbin/vboxsf protocol error on them and I believe its because they dont understand how the SHARE NAME works. some people in older versions of Virtualbox expressed that when they tried to create their Guests folder name the same name as the SHARE NAME that there were conflicts with the vboxsf command. They cured it by changing the name of the Guest folder name slightly different than the Host Shared folder name like Host SHARE NAME is "share" and then the new folder they created was "myshare" and then mounting it. The vboxsf command was getting confused if the name of the SHARE NAME was the same as the guests folder name. I believe Oracle fixed this problem now. if you followed my directions then you would see that it actually can work where the SHARE NAME and the guests folders name can be identical. The problem is I think people are either using the Auto-mount option when they are creating their folder in Share Folders Settings or they changed the "Folders Name:" to something different and that actually changed their SHARE NAME and they are not using the correct SHARE NAME they created. you also possibly thought you had to Share your folder in Windows 7 before you could share it with virtual box but you actually dont have to. And because they are Sharing it in Windows 7 they now are totally skipping the VirtualBox's Shared Folders Option Tool and are believing they can manually still mount with in CentOS. What I was doing wrong that I discovered was that I was thinking I had to Share the Folder in Windows 7. I was still using the Shared Folders Tool but I was selecting both Auto-mount and Permanent. I also didnt understand the vbox command as vboxsf <HOST SHARE NAME> <Guest folder path>. Also there is a typo in your folder path. Like if you are using an / at the end example: /media/share/.

I hope this can clarify for you and also all newbies having trouble with this same problem. Yes Oracle is very vague on their directions in the manual and in their design of the Implementation of the Folder Name is actually the Share Name.
Last edited by CertifiedMuffDiver on 15. Sep 2014, 09:27, edited 1 time in total.
CertifiedMuffDiver
Posts: 2
Joined: 14. Sep 2014, 10:49

Re: Can't mount shared folder in Centos guest

Post by CertifiedMuffDiver »

ohaya wrote:Hi,

I am using VBox 4.3.6, on Windows 7 64 bit.

I have a Centos guest.

In the guest settings, I've created a permanent shared folder named "shared". This is using the G:\ directory on the Win7 machine.

In the guest, I've created a directory, /mnt/myoam.

However, in the Centos guest, I cannot mount the shared folder.

[root@oamoam log]# cd /mnt/
[root@oamoam mnt]# ls
myoam
[root@oamoam mnt]# mount -t vboxsf shared /mnt/myoam/
/sbin/mount.vboxsf: mounting failed with the error: Protocol error
[root@oamoam mnt]#
[root@oamoam mnt]#
[root@oamoam mnt]# mount.vboxsf shared /mnt/myoam/
mount.vboxsf: mounting failed with the error: Protocol error

The VBox tools are definitely installed, and I've looked at the FAQ but can't get this working.

Can anyone suggest anything else to get this working?

Thanks,
Jim

Ohaya, I see your problem in your guests folder path you are trying to mount. you are using /mnt/myoam/ and you dont need to use the last /
you should use /mnt/myoam What you are doing is trying to mount to a empty unknown directory location and pointing past your myoam folder.
Moltke
Posts: 22
Joined: 20. Jul 2016, 21:19

Re: Can't mount shared folder in Centos guest

Post by Moltke »

I know this post is old, but I recently created a CentOS 7 VM and went into that same problem, and now thanks to CertifiedMuffDiver I finally and successfully managed to mount and access my shared folder, so I couldn't leave without say thanks CertifiedMuffDiver!! However, while this works, I could but notice that after every reboot I have to run mount -t vboxsf shared /media/shared, and yes, I've checked the auto-mount option. So, I'd like to know whether there's a way to make this permanent? and thanks again! :D
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Can't mount shared folder in Centos guest

Post by Perryg »

If you use auto-mount you should not need the mount statement at all. This does require you have your user name in the vboxsf group on the guest and a reboot. auto-mount is quick and dirty but I do not use it due to permission issues. Instead I use the manual mount and add the statement to /etc/rc.local which will run the mount for you at boot. This allows me to use option that set the permissions at boot.

Example:
mount -t vboxsf -o rw,uid=<your id>,gid=<your id> shared /media/shared
Moltke
Posts: 22
Joined: 20. Jul 2016, 21:19

Re: Can't mount shared folder in Centos guest

Post by Moltke »

Perryg wrote:If you use auto-mount you should not need the mount statement at all. This does require you have your user name in the vboxsf group on the guest and a reboot. auto-mount is quick and dirty but I do not use it due to permission issues. Instead I use the manual mount and add the statement to /etc/rc.local which will run the mount for you at boot. This allows me to use option that set the permissions at boot.

Example:
mount -t vboxsf -o rw,uid=<your id>,gid=<your id> shared /media/shared
Hi! Thanks for your answer. I agree with you, I shouldn't need the statement at all but I do, otherwise it won't show in the file manager.
Instead I use the manual mount and add the statement to /etc/rc.local which will run the mount for you at boot.

I'm not sure I understand what you mean with this, how do I add the statement, and more importantly, what statement are you talking about? The mount -t vboxsf share /media/share? And I do this on the terminal? Using nano for example? Or I simply run the command "mount -t vboxsf -o rw,uid=<your id>,gid=<your id> shared /media/shared" on the terminal and that would do the job? Sorry, I'm a newbie so please excuse my "newbiness" here and if you don't mind, could you elaborate a little bit more, please? Thank you! :D
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Can't mount shared folder in Centos guest

Post by Perryg »

First run id in a terminal to see what your uid and gid are. Then edit /etc/rc.local with any editor opened in elevated mode. Assuming your uid and gid are equal and also assuming they are 1000 use the example below and add the content above the exit.

Code: Select all

mount -t vboxsf -o rw,uid=1000,gid=1000 shared /media/shared
Moltke
Posts: 22
Joined: 20. Jul 2016, 21:19

Re: Can't mount shared folder in Centos guest

Post by Moltke »

Perryg wrote:First run id in a terminal to see what your uid and gid are. Then edit /etc/rc.local with any editor opened in elevated mode. Assuming your uid and gid are equal and also assuming they are 1000 use the example below and add the content above the exit.

Code: Select all

mount -t vboxsf -o rw,uid=1000,gid=1000 shared /media/shared
Hi again! I've run id and yes, they're both 1000. I opened /etc/rc.local in nano to edit it, but I have 2 questions:
1
add the content above the exit
Do you mean add it at the very end of the file?
2 In etc/rc.local I read this: "Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure that this script will be executed during boot." Do I have to do this after editing the rc.local file? Or just edit the rc.local file, save it and exit and that would be it? without running the chmod command?
Thank you! :D
Moltke
Posts: 22
Joined: 20. Jul 2016, 21:19

Re: Can't mount shared folder in Centos guest

Post by Moltke »

The rc.local file looks like this:
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
where do I add the "mount -t vboxsf -o rw,uid=1000,gid=1000 shared /media/shared" line? below/above the touch /var/lock/subsys/local line? anywhere? Thanks!
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Can't mount shared folder in Centos guest

Post by Perryg »

Yes but there should be an exit 0 as the last line, and your command would be above that or it will not run. The options negate any chmod you would think you needed to do.
Post Reply