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

Sparkly lights silhouette of a person.
Come give us a hug.

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

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.

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.

Featured image by Julien Tromeur.


Comments (31)

Previously posted in WordPress and transferred to Ghost.

Dave
July 10, 2015 at 2:00 pm

Thanks! This really helped me, too.

suri
December 10, 2015 at 1:28 pm

I went through everything you explained in 1. By 2 I got stuck. can anybody help me please??

Siti
August 21, 2017 at 4:57 am

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.

Chris
February 3, 2017 at 10:27 am

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.

Ryan Sechrest
February 3, 2017 at 12:53 pm

Nice! Thank you for sharing that!

Jun
February 10, 2017 at 11:37 am

I followed every step correctly.

Where do i check if it shared in guest OS?

Ryan Sechrest
February 10, 2017 at 1:32 pm

I believe it’s mounted as a disk, so you can use the file explorer that came installed with the guest OS.

Paul
March 14, 2017 at 2:35 pm

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

Sampath
March 21, 2017 at 11:43 pm

Excellent writeup. Worked like a charm.
Thank you so much for the tip.

Ram
May 29, 2017 at 1:16 am

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.

Mikel
June 9, 2017 at 1:38 am

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.

Farah
June 23, 2017 at 10:06 am

This is really helpful!! Thank you very much !

Tamari
July 18, 2017 at 4:54 am

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

Patricia Grubel
December 11, 2017 at 4:40 pm

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

Anish
December 17, 2017 at 6:25 am

This worked like magic. Thanks.

Fabregas
January 3, 2018 at 6:00 am

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

Abhishek Roy
August 15, 2018 at 11:19 am

Great article. Very helpful. Comment from @Fabregas finally helped to get it done. Thanks a lot!

Ajay Gopi
January 18, 2018 at 2:19 pm

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?

harneet
July 15, 2018 at 8:53 am

Worked like charm! host: macos and guest: ubuntu.

Santosh
September 28, 2018 at 4:21 am

Thanks a lot, Tried hard to share and found this, both Bidirectional Drag & Drop and Clip board sharing were not working. This really helped a lot.

Sankar
November 24, 2018 at 9:49 pm

Worked on Mac in which I am running Linux VM! Thanks.

pankaj
February 15, 2019 at 1:45 am

Hi ,
Its not working for me I have MAC book laptop and running Centos VM . Pls help

Amy
March 31, 2019 at 10:56 pm

Thanks a lot! This is the only way that makes my Mac work.

Gabriela
September 9, 2019 at 8:10 am

Thank you! It really helped me!

Kimseng
October 7, 2019 at 5:30 pm

I am not sure I could follow your instruction well.
How can I verify that rc.local running without any error?
Could you help print screen rc.local as reference? since your topic match to my condition.
I use Oracle Linux 6 (Guest) with Mac OS (Host)

Kimseng
October 7, 2019 at 6:30 pm

Dear Friend, it is working for me after I fixed by install Guest Additional CD successfully.
If anyone who did has problem with Guest Addition CD like virtualbox additions module not loaded
For my case I run this command:
# yum install kernel-uek-devel.x86_64
# /sbin/rcvboxadd quicksetup all
and Then restart your guest os.
after login with user that map in rc.local, share folder will appear on user desktop.

Thanks.

Ryan Sechrest
October 9, 2019 at 10:25 am

Thank you for coming back to provide the solution!

Dev
February 6, 2020 at 10:12 pm

Totally late for this post, but glad I found it!

Using Catalina (Host) to Mojave(Guest). After some testing, I realized that I didn’t have to change the rc.local file at all.
– I got this to work by changing Network Adapter (specifically, adapter 1) settings related to VB specific, Mojave (Guest) preferences in VirtualBox Manager area.

– Under “attached to” change from Default NAT to Bridged Adapter & for “name” dropdown, used the very first: en0: Wifi (Airport) which produced an 192 .etc.etc.etc (IP) in place of the 10.etc.etc.etc for the default connection in the Guest , re: Ethernet. Makes sense.

– SMBed to Mojave(Guest) VB env via Catalina (Host, my non-virtual environment) using the Finder->Go->Connect to Server

Ryan Sechrest
February 7, 2020 at 11:43 am

Thanks for posting newer information with regard to setting this up!

Jayashree
September 25, 2020 at 6:20 am

Very helpful writeup. The tips in the comments helped a lot as well. Thanks everyone.