In today’s post, I will show you have to mount a Windows shared folder in Ubuntu 12.04 from within VirtualBox. A prerequisite is that you have to have VirtualBox Guest Additions already installed. If you haven’t done so and would like to know how, read this previous post where I show you how. Otherwise, continue reading and I’ll show you how to mount a shared folder.
Create and mount a shared folder
- Open VirtualBox on your host Windows computer
- Right-click on your virtual machine and select settings
- Select the menu: Devices/Shared Folders…
- Click the Add button
- Navigate to the folder on the host computer that you want to share
- Enter a Folder Name, such as share. This does not have to be the same as the directory itself, but this is the name you’ll use in Ubuntu.
- Check the options that you would like: Read Only, Auto-Mount, and/or Make Permanent
- Click OK
- Create a mount point for the share directory:
$ sudo mkdir /shared_directory
- Type the following to manually mount the shared directory
$ sudo mount -t vboxsf share /shared_directory
- With the above command, the shared directory will be owned by root:root and all directories and files with have 777 permissions. If you would like the files to be owned by you, use the following command. This will also set all directories to have 777 permissions and all files to be 666. Please change your UID and GID accordingly. To more fully understand this command, please see the mount man page.
$ sudo mount -t vboxsf -o uid=1000,gid=1000,dmask=0000,fmask=0111 share /shared_directory
- If you want to have your shared directory automatically mounted every time, there’s a few steps that you’ll need to take. First off, VirtualBox’s Guest Additions automatically mounts the shared folder to /media/sf_share, where share is the name of the shared directory that you defined earlier. This folder has owner of root and group of vboxsf. Therefore, your username needs to be added to the vboxsf group. Type the following to see if you’re already a member:
groups username
- If you’re not a member, then type the following to add yourself to the group, where username is your username:
sudo adduser username vboxsf
- After that, all you have to do is create a symbolic link so that you can access it at the particular mount point that you would like. Type the following to create the symbolic link:
sudo ln -s /media/sf_share /share_directory
That’s it! You now have access to a directory on your host computer from your Ubuntu Virtual Machine. Have fun!!!