What is the procedure for mounting a VirtualBox shared folder in Linux?
I tried variations of the following mount command but I keep getting
protocol error or other mount errors.
sudo mount -t vboxsf share /home/toto
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Ok this was a little confusing for me but I finally realized what was happening. So I decided to give my 2 cents in hopes that it will be more clear for others and if I forget sometime in the future : ).
I was not using the name of the share I created in the VM, instead I used share or vb_share when the name of my share was wd so this had me confused for a minute.
First add your share directory in the VM Box:
Whatever you name your share here will be the name you will need to use when mounting in the vm guest OS. i.e. I named mine "wd" for my western digital passport drive.
Next on the the guset OS make a directory to use for your mount preferably in your home directory.
Next open the terminal and copy and paste the following or type it in. You can enable shared clipboard under Device-> Shared Clipboard-> Bidirectional
sudo mount -t vboxsf wd ~/share/
You should now be able to copy files between OS's using the folder "share" in your home directory.
Hope this Helps!
For VirtualBox with a Linux guest, these are the steps to mount a shared folder:
Use the VirtualBox host's application, VirtualBox Manager, to specify host folders to share.
Make sure VirtualBox Guest Additions are installed in the VirtualBox guest.
In the Linux guest, the mount command should show a line that the share was mounted. This is indicated by
type vboxsf. The issue becomes that the mount point may not be where desired, and the permissions are root only. The default mount location is in
You can access the share by making the user, or group id of
1000, a member of group
vboxsf. This is done by changing the
vboxsf line in the
/etc/group file. May require reboot.
You can change where the folder is mounted by using the VBoxControl command. The command is installed when Guest Additions is installed. May require reboot. For example, to change the mount point from
/home/toto/sf_... use the following command to set the VirtualBox shared folder guestproperty:
sudo VBoxControl guestproperty set /VirtualBox/GuestAdd/SharedFolders/MountDir /home/toto/
To confirm the change, use get:
sudo VBoxControl guestproperty get /VirtualBox/GuestAdd/SharedFolders/MountDir
mount: Protocol error
after trying to share folders in VirtualBox, eg:
$ sudo mount -o uid=1000,gid=1000 -t vboxsf D_DRIVE ~/host
this finally worked for me:
$ sudo apt-get install virtualbox-guest-dkms
(My setup: Windows 7 host, guests: Ubuntu 12.04,13.10,14.04; currently running VBox 4.3.10 r93012)
Install virtual box additions on the guest os. Then shutdown the guest OS. Open the guestos settings in virtual box. Then add a shared folder and save the settings. Then start the guest os and for ubuntu issue the below command. It adds the current user to the vboxsf group.
sudo adduser $USER vboxsf
reboot the guest OS and navigate to /media/ to access the shared folder.
Inside a Linux or Mac OS X VirtualBox guest, once you have installed the VirtualBox Guest Additions, you can discover the available VirtualBox shared folders with following command :
sudo VBoxControl sharedfolder list
If your home folder inside your guest contains folders having same name as VirtualBox shared folders, you can mount them automatically with following shell script :
#!/bin/sh #----------------------------------------------------------------------------- # Discover VirtualBox shared folders and mount them if it makes sense #----------------------------------------------------------------------------- if ! type VBoxControl > /dev/null; then echo 'VirtualBox Guest Additions NOT found' > /dev/stderr exit 1 fi MY_UID="$(id -u)" MY_GID="$(id -g)" ( set -x; sudo VBoxControl sharedfolder list; ) | \ grep '^ *[0-9][0-9]* *- *' | \ sed -e 's/^ *[0-9][0-9]* *- *//' | \ while read SHARED_FOLDER do MOUNT_POINT="$HOME/$SHARED_FOLDER" if [ -d "$MOUNT_POINT" ]; then MOUNTED="$(mount | grep "$MOUNT_POINT")" if [ "$MOUNTED" ]; then echo "Already mounted : $MOUNTED" else ( set -x sudo mount -t vboxsf -o "nosuid,uid=$MY_UID,gid=$MY_GID" "$SHARED_FOLDER" "$MOUNT_POINT" ) fi fi done
When you get the following error: /sbin/mount.vboxsf: mounting failed with the error: Protocol error
Unfortunately this means that you use the default share name or host's share directory name is the same as the mounted guest share name. In this case it is "share". Just create another share folder, i.e. "vb_share" and then just execute:
mount -t vboxsf vb_share /home/< user >/host
mkdir share, for example )
sudo mount -t vboxsf name_of_folder_linked ~/name_of_folder_guest/
Setup: VirtualBox 4.3.26, Win 7 SP1 host, Debian jessie 8.0 (stable) guest.
In VirtualBox Manager, select Shared Folders Settings... in the Devices drop-down menu.
In the resulting pop-up window, select Machine Folders in the Folders List and then click the "Add a New Shared Folder Definition" button (the blue folder with a green "+" sign icon to the right of the Folders List).
In the resulting Add Share pop-up form, click on the down-arrow button in the Folder Path field, and then select Other. A Browse For Folder pop-up window will appear.
(In my case, I had just added another hard drive to my workstation to be used for a dedicated share, already formatted for NTFS, with a volume name of "share", and mounted as "G:". So I clicked the arrow next to Computer, selected drive G: and then clicked the OK button.)
(In your case you should select whatever folder or drive you intend to share, then click the OK button.)
When you've made your selection and clicked the OK button, VirtualBox Manager will fill in the Folder Path and Folder Name fields of the Add Share form. Leave the Folder Path field alone, but you can change the Folder Name if you like -- just be sure to remember it for later.
Finish up the Add Share form by selecting the Make Permanent check box, but be sure to leave the Auto-mount check box cleared -- we're going to take care of mounting later. (And of course, if you want to make the folder or drive read-only, then go ahead and check the Read-only box.) Then click the OK button.
The newly-configured share should now appear as an entry under Machine Folders in the Folders List. Click the OK button.
In order to mount this share during boot (startup) we need to add a mount definition line to /etc/fstab in our Debian jessie guest installation. This edit needs to be done either as root or via sudo, for example:
sudo nano /etc/fstab
(I personally used vi, but because nano is the default editor on Debian jessie I specified it in the above example.)
To mount this share in my home directory, with its ownership and group set to my personal UID and GID, I added the following definition to /etc/fstab:
share /home/conib/share vboxsf comment=systemd.automount,uid=conib,gid=conib,noauto 0 0
(Note that there are no spaces around the "=", ".", or "," characters.)
An /etc/fstab definition is in the form
<Device> <Mount Point> <Type> <Options> <Dump> <Pass>
(Note that there should be whitespace -- space(s) and/or tab(s) -- between the fields of the definition, but no whitespace within a field.)
The "Device" field should be set to the Folder Name we specified via VirtualBox Manager Add Share. I had changed the default "G_DRIVE" to "share".
The "Mount Point" is a directory path spec that must already exist but should be empty. (That is, anything already present in that directory will be hidden by what you're mounting on top of it.) I had created a new, empty subdirectory named "share" in my home directory.
The "Type" is "vboxsf".
The "Options" (comment=systemd.automount,uid=conib,gid=conib,noauto) were the tricky bit, and took a bit of trouble to get working for this setup.
Set "Dump" to 0 unless you know you want it set to something else.
And since we don't want fsck checking this share, set "Pass" to 0 too.
When you've added the definition line to /etc/fstab, reboot your Debian guest and confirm that you can see the files and subfolders of your Share.