71

How do I go about sharing a folder between the host (Mac) and the guest OS (Ubuntu) in Virtual Box?

Abhishek Jain
  • 4,478
  • 8
  • 34
  • 51

1 Answers1

85

You’ll need the latest version of VirtualBox (4.3.10) with Guest Additions installed in Ubuntu.

  • With the Virtual Machine powered off and selected in VirtualBox, go to: Machine > Settings ... > Shared Folders
  • For “Folder Path”, click the icon to browse for the folder you want to share.
  • For “Folder Name”, enter a name to describe the share.
  • Click “OK” and start the virtual machine again.
  • Create a mount point which is basically an empty folder.
  • Fire up the terminal and type: sudo mount -t vboxsf folder_name path_to_mount_point folder_name is the name you typed in earlier to describe the share
  • You should be able to browse the shared folder now.

In case of difficulties mounting the same, such as the following error:

mount: wrong fs type, bad option, bad superblock on mydata,
   missing codepage or helper program, or other error
   (for several filesystems (e.g. nfs, cifs) you might
   need a /sbin/mount.<type> helper program)
   In some cases useful info is found in syslog - try
   dmesg | tail  or so

perform the following steps:

sudo rm /sbin/mount.vboxsf
sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
Abhishek Jain
  • 4,478
  • 8
  • 34
  • 51
  • this does not add it permanently, it only does it until the next shutdown. – eleijonmarck Feb 27 '15 at 14:46
  • 1
    I did all of this and it still just silently fails, meaning all the GUI interactions with VirtualBox > ... > Devices seem to be correct and all the "sudo..." commands on the Ubuntu guest seem to return with no error messages, but the host folder on the mac is still not visible on the guest Ubuntu virtual machine. – Reb.Cabin Jun 23 '15 at 12:47
  • 8
    What's `path_to_mount_point` ? Full path from host OS shared directory? – ismailsunni Sep 28 '15 at 01:24
  • 45
    If "Auto-Mount" and "Make Permanent" are selected for each shared folder, you don't need to run any `mount` commands. To use the shared folders (which will appear under `/media` with `sf_` prefixes), you simply need to add yourself to the `vboxsf` group (e.g., `sudo usermod -a -G vboxsf [username]`). http://www.virtualbox.org/manual/ch04.html#sf_mount_auto – theDrake Nov 02 '15 at 03:14
  • 3
    @theDrake please write that as a separate answer. – Lim H. Nov 14 '15 at 09:14
  • 1
    I'd love to, @LimH., but it appears I can't add a new answer. Perhaps because this question was closed as off-topic? – theDrake Nov 16 '15 at 03:26
  • A lot of people are using vagrant on top of virtualbox. We had a lot of problems with Mac hosts until we started using NFS - details here... https://www.vagrantup.com/docs/synced-folders/nfs.html – brianlmerritt May 26 '16 at 16:25
  • 9
    Just complementing @theDrake 's answer, you need to reboot the VM after running this command – Guilherme Garnier Jan 05 '17 at 10:04
  • @ismailsunni you figured what path_to_mount_point actually is? For me it does not seem to work – trainoasis Nov 09 '17 at 11:08
  • 1
    @theDrake and Guilherme Garnier 's comments should actually be combined together for another answer, _or_ the current accepted answer should be edited to include both these comments. – Ganesh Tata Aug 30 '18 at 05:26
  • 1
    I followed till the `4th point` then opened Ubuntu and typed this in terminal -> `sudo adduser user_name vboxsf` and restarted. Then find the shared folder in /media but this didn't work for many users so type this in terminal and `sudo apt-get install virtualbox-guest-dkms` and then rebooted. And this worked for me. – asn Nov 01 '19 at 12:57