10

I have Ubuntu 12.10 as Host OS and FreeBSD 9 as Guest OS in Virtualbox 4.1.18. I have Samba installed in both Ubuntu and FreeBSD and shared a few folders from virtualbox, also ticking the automount option.

I have also done right click and share in Ubuntu. But when I try to mount in FreeBSD using

mount -t vboxfs sharedfolder /home/user/shared`

it says sharedfolder operation not permitted. I also used

mount_smbfs //10.0.0.2/sharedfolder /home/user/shared

but I get can't get server address

How to share folder/files between Host Ubuntu and Guest FreeBSD from virtualbox ?

5
  • Do you have any reason for not using NFS?
    – peterph
    Mar 15, 2013 at 18:41
  • 1
    NFS ??? How to ? or is it installed by default ?
    – user34260
    Mar 18, 2013 at 9:55
  • 2
    Network File System should be installed by default and if not, you can install it as any other packages. It is the most prominent network file system for Unices.
    – peterph
    Mar 18, 2013 at 17:35
  • BTW, most likely sharedfolder: Operation not permitted means that only root can do that.
    – Apostle
    Jun 16, 2015 at 15:08
  • "Shared Folders for FreeBSD guests are not supported yet" - see my answer below Jun 21, 2015 at 20:28

4 Answers 4

11

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.

4

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:

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.

8
  • I use NAT, the default network for GuestOS. I tried with mount vboxsf even with su, but no any luck. I have shared folder under virtualbox shared mechanism, settings and Shared Folders and gave name sharedfolders for the ones that I wanted to share. I also used automount option available while sharing using virtualbox.
    – user34260
    Mar 18, 2013 at 10:14
  • @JhilkeDai As I said, you can only used the vboxsf and Shared Folder if you have installed the Guest Additions inside the Guest OS, for which I gave you a few links. Did you install them? For Samba, try to use "Bridge" mode, share a folder on the Host (Ubuntu) and try to access it from the Guest (FreeBSD) using smbclient -L <ubuntu hostname>.
    – Huygens
    Mar 18, 2013 at 20:22
  • yes, the Guest Additions were the trick in GuestOS, I never guessed it could be like that, neither I understand how it works. But it works :D
    – user34260
    Mar 21, 2013 at 14:19
  • 1
    Adding the Guest Additions is like adding a set of new drivers to your Guest virtual machine. For an analogy in non-virtual environment, it is like installing a Graphic card without the drivers, you do not have access to all possibilities. Once you install the drivers you can get all features because the OS is aware of them and offer to make use of them to users.
    – Huygens
    Mar 22, 2013 at 7:36
  • 1
    Sorry for being harsh, I have been bitten badly after trusting the answer and spending lots of time trying to use it until reading the other answer. Jun 19, 2015 at 5:01
3

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.

1
  • 1
    Says "not fully working" on the GitHub. And hasn't been updated since January 11 -- the day after you posted your answer :)
    – Mikhail T.
    Dec 26, 2017 at 20:19
2

As of today (2020-05), all ways to mount host folders using native vboxvfs formally work:

mount_vboxvfs -w myshare /mnt
mount -t vboxvfs myshare /mnt

The only problem here is the result is very unstable (host used was FreeBSD 12). I've tried different combinations of guest OS versions (FreeBSD 11 and 12), host I\O cache flag in controller settings, read-only mount flags etc - nothing brings stable work. Files appear\disappear, you will see all kind of glitches like e.g. folder behaves as a file etc. I've got many kernel panics in guest OS too.

So the only valid way to share folder from host OS to "FreeBSD Guest" is using NFS. This works really great, without issues so far.

You must log in to answer this question.