Share Folders Between a Linux Host and Linux Virtual Machine on VirtualBox
VirtualBox is a great application for trying out different Linux distros without messing with your current build. In this post I'll show you how to share a folder between your Linux host and the guest virtual machine. This assumes you have already installed VirtualBox, created and installed your guest OS, and installed VirtualBox Guest Additions.
On you host machine, create a folder to share. I'll call mine vbox.
Start up your guest OS in VirtualBox. In the window for the running virtual machine, select Devices->Shared Folders... Click the icon to Add a New Shared Folder. Select the Folder Path drop-down and click Other. Navigate to your shared folder and click Choose.
Click OK twice. That was the easy part.
Go into your guest OS and open a terminal window.
Create a new directory where you'll mount the shared folder.
Enter the id command and look at the output. You should see something like:
uid=1000(user) gid=1000(user) groups=4(adm),20(dialout),24(cdrom),46(plugdev),106(lpadmin),121(admin),122(sambashare),1000(user)
It's the uid and gid parts that are important. Now you will mount the shared folder from the host to the guest OS. From a terminal in the guest OS:
Make sure to make the proper substitutions for uid and gid as well as the host and guest folder names (vbox and /home/user/share respectively).
You should now be able to share files between your guest and host.
Make the Mounted Share Permanent
You can make the shared folder mount automatically each time you start the virtual machine by making an entry in /etc/fstab. From the guest:
Add a line at the bottom that looks like this:
vbox /home/user/share vboxsf rw,uid=1000,gid=1000 0 0
Again, make the appropriate changes for your folder names and user/group ids.