Permanently share a folder between host (Mac) and guest (Linux) OS using VirtualBox

This is mainly for my own reference, but here it goes.

1. Share a folder on the host OS

  • In VirtualBox, click your OS on the left and click on Settings.
  • Click on the Shared Folders tab.
  • Click on the folder with the plus on the right.
  • Browse to a folder of your choice in the folder path.
  • Enter a folder name with no spaces e.g. “Share”.
  • Check Auto-mount and Make Permanent, if available.
  • Click on OK.

2. Mount the folder in the guest OS

  • Create a folder in your guest OS that you want to share.
  • Open up Terminal.
  • Type in id and press ENTER— remember that ID.
  • Switch to the root user using sudo su and enter your password.
  • Browse to the etc folder using cd /etc.
  • Edit the rc.local file using vi rc.local.
  • Move your cursor right above exit 0 and press the letter “i” on your keyboard to insert text.
  • Type in the following: sudo mount -t vboxsf -o uid=1000,gid=1000 Share /home/username/Documents/Share
    • 1000 should match the ID you noted down earlier.
    • Share should match the folder name from step 1.
    • username should match your Linux username.
    • /Documents/Share should be the absolute path of the new folder you created.
  • Now hit “ESC”, type :wq and hit ENTER to save and quit the file editing.

After you restart the guest OS, your shared folder will be automatically mounted.

24 thoughts on “Permanently share a folder between host (Mac) and guest (Linux) OS using VirtualBox

    1. Siti

      I’m totally lost when it comes to “2. Mount the folder in the guest OS”. I’m using mac – sierra as a host and windows 10 in Virtual box. I’m stuck from point 2.2 “open up Terminal” onwards. What is Terminal? How do I move on to the rest..? DO you by any chance has a picture as an example to summarise these steps? Many thanks in advance for your help.

  1. Pingback: Rails: Ubuntu Virtual Development Environment on Window « Angkor Brick

  2. Chris

    Thanks for the instructions!

    I needed to make 2 small changes in order to get shared folders to work with my Linux guest:

    1. In VirtualBox VM shared folder settings, do not enable Automount.
    2. As root on Linux guest, do chmod +x /etc/rc.d/rc.local without which the rc.local commands will not be executed.
  3. Paul

    hello, i followed all the steps correctly but i still cant see me “shared” folder mounted anywhere what should i do?

  4. Ram

    Very helpful. For those who might not see the files in the shared folder, try from terminal
    ls /home/username/Documents/Share and now if you see the data but not in the file viewer, then go to /home/username/Documents/Share in the file viewer and on the top menu go to view tab and select reload folder or F5.

  5. Mikel

    If you want to add a user to a group in Fedora, do the following:

    Open a terminal.
    Enter su -, hit Enter.
    Enter the root password, hit Enter.
    Type in usermod -a -G vboxsf username, replacing username with the user you want to add to the group, hit Enter.
    You may have to reboot to remount the share, the easiest way to do this is probably to reboot the VM.

  6. Tamari

    thanks – works great.
    to find your shared folder run df -H
    in my case it’s mounted on /media/sf_NAME

  7. Patricia Grubel

    Works great. Just one note, look for links to rc.local and make sure the file has the execute permission.
    In my case: sudo chmod +x rc.d/rc.local

  8. Fabregas

    In addition to the above steps I had to install GuestAdditions using `sudo apt-get install virtualbox-guest-utils`

  9. Ajay Gopi

    Hi I tried to mount the file to my guest OS (Mac OS Sierra) but I got a blue screen when I tried to restart the Ubuntu OS (it is Ubuntu 16.04). Do you know why this might be happening?


Leave a Reply

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