Find Me On

My Homepage





RSS Feeds

My Stuff

Shared Items

Search This Blog


Josh Braun’s Blog // I have it written down somewhere . . .

Setting Up VirtualBox Shared Folders Dec 31, 2012

In my previous post on installing Arch Linux in VirtualBox, I’d mentioned that I’d eventually add information on sharing folders and files between Arch and the host operating system.  I wasn’t going to get around to writing this up for a while, but a question came up about it in a discussion on the Arch forums, so I ended up doing it sooner than later.

folderHere’s how I’ve configured shared folders on my own VirtualBox install of Arch Linux.  These instructions should work for other Linux distros used with VirtualBox as well, but the usual disclaimers apply—this worked for me, but your mileage may vary and there’s no warranty here express or implied.

The System

Everyone hates outdated instructions, so I’m going to include the version numbers I’m working with.  The instructions in this guide were executed on a 13-inch MacBook Pro (early 2011 model) running Mac OS X 10.7.5 (Lion) and VirtualBox 4.2.6.  The Arch guest OS is running Guest Additions packages from the Arch community repository, the version numbers for which are virtualbox-guest-utils 4.2.6-1 and virtualbox-guest-modules 4.2.6-3.

Setting Up Shared Folders

Note that before you can begin, you need to have installed and configured the VirtualBox Guest Additions in Arch.  These instructions assume that you’ve done so already.

  1. Create a folder on your host OS to be shared with your Arch Linux guest.  Note that this folder has to be in a location that’s not “owned” by a particular user of your host OS.  There’s some weirdness to this, as it appears to be about more than just the permissions assigned to a particular folder.  I’ve found that on OS X, creating a folder either in the ~/Public folder (<–this is where I put my shared folder) or on the Desktop works, while creating a folder in the ~/Documents directory does not, despite the fact that the permissions for some of these different directories are similar.  Also, at this stage, place a text file or some other file in the folder—later on, if you can see and view the contents of this file from within Arch you’ll know the folder’s been shared successfully
  2. Identify the shared folder in your VM’s VirtualBox settings. In the VirtualBox Manager window, prior to booting your VM, select your Arch Linux guest and go to “Settings > Shared Folders”.  Click the folder icon with a plus on it to add a shared folder.  For “Folder Path” open the dropdown menu and select “Other…” to launch your host OS’ file browser.  Select the folder you created on your host OS in step one.  For “Folder Name”, if it’s not autofilled, enter a name for the folder to identify it to the Arch Linux guest—to avoid dealing with escape characters and so forth later on, I generally make this something simple, like “Shared”, and avoid spaces or special characters.  For simplicity’s sake, I also usually make this name the same as the name of the folder I created in step one.  “Read Only” should be left unchecked, assuming you want to be able to add files to the shared folder from within Arch.  Also, leave “Auto-mount” unchecked—there’s an alternative configuration in which you leave this checked, but for present purposes it shouldn’t be.  Finally, check “Make Permanent” to have the folder available every time the Arch guest is booted.  When you’ve filled out the form and clicked ‘OK’ your new folder-to-be-shared should appear in the “Settings > Shared Folders” window under the list of “Machine Folders”.
  3. Boot your Arch Linux VM.   Log in with your normal user account (i.e., not as root).
  4. Create a mount point in Arch for the shared folder. By this, I mean create a folder in Arch where you want the contents of the shared folder on the host OS to appear.  I usually create this folder in my home (~) directory and, for consistency, name it the same thing I named the folder on the host OS, which is also the same “Folder Name” name I gave when identifying it in the VM settings.
  5. Test the availability of the shared folder by manually mounting it.  Momentarily, we’ll automate this process, but before we do it’s a good idea to make sure everything’s working correctly.  This is an example of the command to run, which I’ll explain subsequently:

    # sudo mount -t vboxsf -o gid=1000,uid=1000 Shared /home/josh/Shared

    In the above command,

    • sudo is obviously to invoke administrative privileges, which are needed to mount the folder;
    • mount is the mount command;
    • -t is a flag specifying the type of thing to be mounted, which is a Virtual Box shared folder (‘vboxsf’);
    • -o is the options flag, which is there so we can invoke the option to make the folder writable for the users in the group with the number 1000 (gid=1000) and the particular user with id number 1000 (uid=1000).  Assuming this is a personal install and you created only one non-root user account for yourself, user 1000 in group 1000 will beyou, however if you’ve got multiple user accounts or have set up weird group privileges, you may need to look up the group and user id that apply to you;
    • ‘Shared’ is the name you gave as “Folder Name” in step two;
    • ‘/home/josh/Shared’ is the absolute path to the folder you created in step four (my username is ‘josh’).  Note that you have to give this filepath without any shortcuts or symlinks (i.e., ‘~/Shared’ will not work).

    Note that if you want to temporarily share a folder between your guest and host in the future, you can use this same ‘mount’ command in conjunction with VirtualBox’s “Devices > Shared Folders” menu while the VM is running.  The only difference is that the folder you share using “Devices > Shared Folders” will be added to a list of “Transient Folders” rather than the “Machine Folders” list, meaning that it will only be available for the current VM session.

  6. Test the shared folder.  Once you’ve run this command, you should be able to see and view the contents of any files you’ve placed in the shared folder on the host OS by navigating to the mount-point folder you created from within Arch.  You should also try copying a file from your Arch system into the shared folder to see if it shows up on the host OS.  If not, you may not have write privileges for the folder, and you should check (1) the folder permissions on the host, as well as (2) the uid/gid you used in your command to make sure they correctly apply to your user account.
  7. Add instructions for mounting the folder to /etc/fstab.  If everything’s worked up ’til now, you can go ahead and add instructions for mounting to the folder to your /etc/fstab file.  This will automatically mount the shared folder in the future when Arch boots.  At the end of my /etc/fstab file, I placed the following:

    # VirtualBox Shared Folder Shared /home/josh/Shared vboxsf uid=1000,gid=1000 0 0

    While the order is slightly different, you’ll see that all of the options set here are identical to the ones used in the ‘mount’ command above, so you should set them to whatever the personal equivalents are that you used previously.  The only exceptions are the last two zeroes, which you should just leave as is.  These turn off Linux’s file system backup (‘dump’) and file system check (‘fsck’) for the shared folder, neither of which is needed here.

  8. Reboot Arch. At this point, you should be able to reboot Arch and, if everything’s worked correctly, the shared folder should be automatically mounted for you.

Alternative Configurations and an Important Note on the ‘Auto-mount’ Feature

Lastly, I should mention how the method I’ve described here is different from alternatives that some other people use, so there’s no confusion if or when you encounter a forum thread at some point in which people have done it differently.  Some other folks will use much the same process I’ve outlined, but instead of having ‘fstab’ mount their shared folder will instead create a systemd configuration file or initscript to do the same thing.

Still other folks will check “Auto-mount” in step two above, and omit my steps 4–7.  Instead, they create user privileges for Guest Additions within Arch that allow the Guest Additions software to mount volumes by itself.  Guest Additions will then automatically mount the shared folder as an external drive that shows up under the ‘/media’ directory.  I’ve never tried this method personally, but if you wanted to, you could find instructions on doing so with a bit of Googling.

Note that if you use my configuration, you should leave ‘Auto-mount’ unchecked—if you leave it checked, things will work just fine when you boot and while you’re working, but will cause problems when you try to shut down the VM.  At that point, VirtualBox’s ongoing attempt at connecting to the VM as a removable device, hitherto harmless, causes Arch to wig out as it’s unmounting and closing down all the virtual hardware.  This usually induces a slew of error messages ending in a kernel panic (on the VM), and the need for a hard shutdown of the virtual machine.

That’s it!  Hopefully this works for you, and feel free to leave your own critiques, comments, or alternative configurations in the comments.

This entry was posted in Journalism, New Media & Digital Culture and tagged , , , , , . Bookmark the permalink.
  • Raeki

    Great description/explanation (always wondered what automount was) – thanks! Can you suggest an alternative? Gedit doesn’t play well with virtualbox shared folders… (google search “virtualbox gedit” reveals problem dates back to 2009)

  • kevin


    Ok up until I run sudo mount….
    Error message /sbin/mount.vboxsf: mounting failed – No such device.
    I ran sudo modprobe vboxsf and then ran sudo mount… and it worked.

    Added line to /etcfstab. On reboot folder did not mount.

    I found I had to run sudo modprobe vboxsf again and then mounted folder and was ok.

    Any ideas of the problem. Thanks

    • Rabi Shankar

      You can add `vboxsf` to the list of modules loaded at startup.
      On Gentoo systems it is ‘/etc/modules.d/’.
      Else simple do `systemctl enable virtualbox-guest-additions` (equivalent in your distro) which will take care of loading all the required virtualbox modules.