search
top

How To Connect to a Local Directory on a Windows Host with a Linux Guest in VirtualBox

Recently I felt the need to retrieve files from my Windows host on my Linux guest in VirtualBox 4.2.6. This is an easy task with the VBoxAdditions installed on the guest OS and a simple change in the shared folders in VirtualBox.

If VBoxAdditions are not installed on the guest host you must first get them installed. If you are running Fedora 17 or 18 look here for the instructions.

Next make sure to power off the guest VM and once powered off open the Settings for the VM and click on Shared folders.

shared1

Click on the add folder icon on the right side and a dialog box will open asking for the folder to add, you can type in the path ex: c:\Download or browse for it by selecting the drop down and select Other.

shared2

Insert a Folder Name and select Auto-mount. Click OK to accept the changes and restart the guest VM.

shared3

Once you have logged into your Linux VM you are ready to create a directory to mount and then mount the shared folder. In this example I have created the /mnt/share folder. Now all that is needed is to execute.

$ sudo mount -t vboxsf Download /mnt/share

Now we can get to the files but this command will have to be run every time, so why not create a shell script called mntshare.sh and just populate it with the exact command you ran. Now each time you start the VM you just run ./mntshare.sh.

Note that with this, the default mount options are used and all files are owned by root. This can be changed by adding some mount options. Options are passed on with the -o parameter. You can use multiple options with one parameter, separate the values with a comma.

$ sudo mount -t vboxsf -o uid=1000,gid=1000 Download /mnt/share

And that is all there is to creating and accessing a shared folder in VirtualBox.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top