Virtualbox: Mount a shared folder in Guest FreeBSD from Host Ubuntu

As pointed out at another topic,

Shared Folders for FreeBSD guests are not supported yet [...] There is some draft code and a kernel module for it but it's not working yet.

That is as of Jun 24, 2014.


Samba

It is possible to mount either a shared FreeBSD folder or a shared Ubuntu folder with samba. Both ways work. Either case you need to configure a share folder (you mentioned you used the Ubuntu GUI to do that) and then on the other machine you need to mount the share using the correct IP and making sure that both the Guest and Host are on the same network or using port forwarding in case you had NAT configured.

Because there is too many solutions, I am not going to list them all here. Please could you provide more information regarding the network configuration of your Guest OS? What settings did you use when creating the VM? Do you use NAT, Bridge, Host-only or Internal Network? I'm going to provide you with one example which assume that your guest is able to view on the network your host (for example, you have one network card defined as host-only).

First share a network folder on Ubuntu as you did. Make sure to create a user account in Samba on the Ubuntu host or that guest access is possible (e.g. sudo smbpasswd -a <username> to give access to a user, replace by the username.

Then on FreeBSD, mount the Ubuntu share by using the correct IP address (10.0.0.2 is probably the one for your NAT "router" created by VirtualBox and therefore it probably won't work), for example either use the Ubuntu IP address on your LAN (e.g. 192.168.1.x) or the one that was defined for the host-only interface. Then your mount_smbfs command will succeed:

mount_smbfs -U <username> //<correct IP>/sharedfolder /home/user/shared

vboxsf

When vboxsf gets supported by FreeBSD (thanks Alexander for pointing that out) and if you want to use VirtualBox builtin share mechanism with vboxsf, you need to install the Guest Additions in the Guest OS (some FreeBSD in your case). Usually this is done via the VirtualBox menu under Devices, there is a shortcut to Install Guest Additions....

However, for FreeBSD you have to do it differently. They have a dedicated documentation for this:

  • FreeBSD Wiki About VirtualBox
  • FreeBSD handbook (see at the end of the page)

Once the Guest Additions installed, you can use the mount command with the vboxsf filesystem. You need however to share a folder using VirtualBox share folder mechanism, see under VirtualBox's Devices menu the item Share Folders.... Note that the name you will give to the share in this menu will be the name of the "device" you give to mount.


There is a port available on github:

https://github.com/lwhsu/freebsd-vboxfs

It is tested to work successfully on FreeBSD 11.0-RELEASE-p1.