- How to access a shared folder in VirtualBox?
- 10 Answers 10
- Access to shared folders in Virtual Box
- Command line
- Auto-Mount through Virtual Box Manager
- First, please make sure you have installed the Guest Additions
- Second, add your user to the group ‘vboxsf’:
- Reboot
- Mount VirtualBox shared folder on Ubuntu or Linux guest
- Mount VirtualBox Shared Folder on Ubuntu
- Mount VBox Shared Folders Ubuntu / Debian Guest
- VitualBox Shared Folder Permissions
- Manually Mount VBox Shared Folder on Ubuntu
How to access a shared folder in VirtualBox?
I followed the steps for sharing folders between Windows 7 and Ubuntu in VirtualBox. Despite that the folder appears with a X sign and gives me the following message when a try to open it:
On the system page, you have assigned more than 50% of your computer’s memory (2.93 GB) to the virtual machine.
10 Answers 10
Access to shared folders in Virtual Box
Command line
By default, VirtualBox shared folders are created with read/write permission for the guest. This can be done from the command line on the host with:
VBoxManage sharedfolder add "VM name" --name sharename --hostpath "C:\test"
By adding the option —readonly we can restrict these for read-only access. Use the —transient option if you only want the shares to appear in the present session but not persistent for following sessions. There are some limitations for shared folders (see this question for details). If prerequisites are met we may mount these shared folders manually by running the following commands in the guest:
mkdir /home//vboxshare sudo mount -t vboxsf -o uid=1000,gid=1000 sharename /home//vboxshare
Of course, we can also use different mount options to mount as read/only or mount with read access only to root.
Auto-Mount through Virtual Box Manager
In case we enabled auto-mounting on creating a shared folder from the Virtual Box Manager those shared folders will automatically be mounted in the guest with mount point /media/sf_ . To have access to these folders users in the guest need to be a member of the group vboxsf .
sudo usermod -aG vboxsf $USER
The guest will need to restart to have the new group added.
Source and further reading: Virtual Box User Manual
i set a shared folder in the GUI and also set the Auto-Mount. restarted the VM, went to /media but still nothing there
This command, suggested by another answer here, seems clearer and has better output: sudo adduser your_username vboxsf
@JordanBrough: totally correct — all ways lead to Rome. You can even use a graphical frontend users-admin . The command was edited in by another user.
Thanks for your answer.. in the command you mentioned above sudo mount -t vboxsf -o uid=1000,gid=1000 share /home/
Actually there is an easy way to do that:
- Install the extension pack for VirtualBox.
- Restart your virtual machine
- Install Guest Additions in your guest Ubuntu
- You can mount the ISO which is on /media or press Left Control + D
sudo adduser your_vm_username vboxsf
THIS. I wasn’t in the user group. Seems like that should have been automated by the gest additions or at least stated clearly.
@Atcold Logging out and in again adds the group to the current user (session) but did not trigger auto-mount of the shared folder in my case. Only a reboot did.
First, please make sure you have installed the Guest Additions
- Start your VM
- Devices > Insert Guest Additions CD image.
- Mount the CD:
sudo mount /dev/cdrom /media/cdrom
sudo apt-get install make gcc linux-headers-$(uname -r)
sudo /media/cdrom/VBoxLinuxAdditions.run
Second, add your user to the group ‘vboxsf’:
~$ echo $USER; ahmed ~$ sudo usermod -a -G vboxsf ahmed
Reboot
Know that the label of your shared folder is lpi (for example):
Prepend sf_ to the label. Then, you will find your shared folder under /media/sf_lpi
Finally, you can also create a link to your home. For example:
ln -s /media/sf_lpi /home/ahmed/lpi
Can I use a shared folder from an Ubuntu VM without a harddisk image, but with only a Live CD image? Basically I am trying to add two CD drives, one holding the Ubuntu Live CD, and the other one holding the VBGuestAdditions.iso, and start the machine, then install VBGuestAdditions in the loopback root, and then I would like to be able to access a shared folder.
Also, is there a way to see the shared-folder before mounting, such as by using a command like lsblk or something?
When I try to do «sudo mount -t vboxsf mysharename mysharemountpoint», I always get: «/sbin/mount.vboxsf: mounting failed with the error: No such device»
Add the shared folder to the virtual machine using vBox graphical interface Make sure to select automount and make permanent
Login to the virtual machine using a root account
Check vboxsf group exists
~$ grep vboxsf /etc/group vboxsf:x:125:
Check user is not already in vboxsf group
~$ id nilo uid=1000(nilo) gid=1000(nilo) groups=1000(nilo),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare)
Add user nilo to vboxsf group
~$ sudo usermod -a -G vboxsf nilo
~$ id nilo uid=1000(nilo) gid=1000(nilo) groups=1000(nilo),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),125(vboxsf)
Reboot and login as nilo
Shared folder is now accesible in /media/sf_dropbox (dropbox is the name I gave to the share)
Share a folder between Host OS-> Windows and Guest OS ->Ubuntu(Virtual box)
Step 1 Install install Guest Additions from VirtualBox’s menu go to Devices->Install Guest Additions This will mount a virtual CD on your /media/cdrom. As root user Open this /media/cdrom added folder using Open with terminal option(Right click with mouse).
Step 2 Run the program VBoxLinuxAdditions.run. When the program completes reboot your VirtualBox.
$ sudo ./VBoxLinuxAdditions.run
Step 3 Create a shared folder. From Virtual menu go to Devices->Shared Folders then add a new folder in the list, this folder should be the one in windows which you want to share with Ubuntu(Guest OS). Make this created folder auto-mount. Example -> Make a folder on Desktop with name Ubuntushare and add this folder.
Step 4 When done with you shared folder(s) specification, we mount folder from Ubuntu(Guest OS). Create a mountpoint, this a directory in Ubuntu that will share files with the shared folder from Windows. Run this to create a directory in Ubuntu
$ sudo mkdir ~/Desktop/windowsshare
Step 5 With your mountpoint created you can now mount the shared folder. Run this command to share the folder:
$ sudo mount -t vboxsf Ubuntushare ~/Desktop/windowsshare
Ubuntushare is the name of folder we add in VirtualBox Devices section this folder is in Windows(Host OS). ~/Desktop/windowsshare is the directory in Ubuntu(Guest OS)
CONGRATULATIONS-> Now you can share the files between Windows and Ubuntu. Try adding any file in windows(Host OS) Ubuntu share folder now check Ubuntu(Guest OS) windowsshare directory the file will be reflected.
Mount VirtualBox shared folder on Ubuntu or Linux guest
You may have setup VirtualBox shared folder as we had previous described but you cannot use it or copy files to it until you mount VirtualBox shared folder on Ubuntu or Linux guest OS. Setting up a shared VBox folder allows you to easily share files between host OS and guest OS. This post shows how to mount VBox shared folder on Ubuntu guest. This method works on almost all Linux distributions.
Mount VirtualBox Shared Folder on Ubuntu
The steps for mounting VBox shared folders is different for Windows and Ubuntu / Debian. Windows guide for mapping VBox shared folder will be published next. This guide only shows how to mount VirtualBox shared folder on Ubuntu and other Linux guest OSes. Host OS on which Oracle VirtualBox VM is installed can be anything.
Before you try to mount a shared folder as described in this guide, make sure that you have setup shared folder on VirtualBox.
Recommended HTPC / Home Server Builds:
Mount VBox Shared Folders Ubuntu / Debian Guest
Mounting VirtualBox shared folders is easy on Linux guest OSes. If you enabled Auto-mount while creating shared folder then it should automatically be mounted to /media/USER/sf_ShareName or /media/sf_ShareName , depending on your guest OS.
In the example shared folder shown in the picture above, Folder Name is also known as ShareName . Its mount point will be: /media/htpcbeginner/sf_Share or /media/sf_Share , depending on the guest OS. Username htpcbeginner will be different in your case. Navigate to these folders to access the files.
VitualBox Shared Folder Permissions
You may encounter permissions issues when trying to access VirtualBox shared folder on Ubuntu (or other Linux distros). The shared folder is mounted with 770 permissions with root user and vboxsf as the group. Therefore, you need to enable root (administrator privileges) to access the shared files. But this can be inconvenient and you may want to the current user (you) to be able to access the files without having to enable root or opening your file explorer with root privileges.
To mount VirtualBox shared folder on Ubuntu and access everything within the shared folder as the user, in this example htpcbeginner , you will have to manually add the user to vboxsf group using the following command:
sudo usermod -a -G vboxsf USER
Of course, replace USER with your username. Once done, the user will have read/write access to the VBox shared folder. For easy access / convenience, you may create a symbolic link to the mounted shared folder in your home folder:
sudo ln -s /media/htpcbeginner/sf_Share /home/htpcbeginner/Share
Note that /media/htpcbeginner/sf_Share could be /media/sf_Share depending on how your Linux OS mounts VBox shared folder. Also, replace htpcbeginner with your username. Once done, you will have a symbolic link created to the Vbox VM shared folder in your home directory as shown below.
Manually Mount VBox Shared Folder on Ubuntu
Now what if, you did not automount the shared folder? You may go to Device -> Shared Folder Settings , edit the shared folder, and enable Auto-mount. You may also check «Make Permanent» if you want the mounting to stick on reboot. Alternatively, you may manually mount VirtualBox shared folder on Ubuntu or Linux, anytime, using the following command:
sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) ShareName NewFolder
Replace ShareName with Folder Name from the first picture and NewFolder with desired folder name (could be same as ShareName ). Using this command to mount VirtualBox shared folder on Ubuntu / Debian will automatically enable read/write permissions for the current user. These mounting instructions work on all Linux distributions.
Using fstab to auto-mount VirtualBox shared folders during boot does not work in recent versions of Ubuntu as VirtualBox services start after the filesystem is mounted. You may encounter «no such device» error as OS cannot find the shared folder to mount. The OS may stop booting. Hence, enabling Auto-mount in the Shared Folder Settings and adding the user to vboxsf group is the way to setup automount during boot with required permissions. So there you go, mount VBox shared folder on Ubuntu or other Linux guest OSes, and enjoy seamlessly sharing files between the two OSes.
Complete Guide to Setting Up a Home Server on VirtualBox Virtual Machine:
- Install VirtualBox — Windows 7/8/10 / Ubuntu/Debian
- Install VirtualBox Extension Pack — Linux and Windows Host
- Install Guest OS on Virtual Box — Ubuntu Server
- Install VirtualBox Guest Additions — Windows Guest / Linux Guest
- Update VirtualBox Guest Additions — Windows Guest / Linux Guest
- Setup VirtualBox Shared Folder — Windows and Linux
- Mount VirtualBox Shared Folder — Windows Guest / Ubuntu Guest
- Access USB Drive on VM — Windows and Linux Guest
- Configure Home Server on VirtualBox — Ubuntu Server