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.

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

  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.
    Reply
  3. Paul

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

    Reply

Leave a Reply

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