Vagrant: VBox Shared Folders on FreeBSD Guest Error Out

Created on 13 Aug 2017  ยท  12Comments  ยท  Source: hashicorp/vagrant

Edit Since I closed this, VirtualBox has added support for VBoxSF on FreeBSD hosts as well as guests.

Hi guys! When I boot a FreeBSD guest with my Vagrantfile, I receive the following message.
Vagrant is not able to mount VirtualBox shared folders on BSD-based guests. BSD-based guests do not support the VirtualBox filesystem at this time.
The error goes on to state that this is not a bug in Vagrant, however this is untrue.
With the port virtualbox-ose-additions,
one can simply run mount -t vboxsf Vagrant /vagrant to mount the VirtualBox Shared Folder inside a FreeBSD guest. They function the exact same as they would in Linux, at this point.

Vagrant version

Vagrant 1.9.5

Host operating system

FreeBSD 11.0 x64

Guest operating system

FreeBSD 11.0 x64

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "freebsd/FreeBSD-11.0-RELEASE-p1"
  config.ssh.shell = "sh -c 'SH_ENV=/etc/profile exec sh'"

  config.vm.define 'dev-genericname', autostart: false do |genericname|

    genericname.vm.box = 'freebsd/FreeBSD-11.0-RELEASE-p1'
    genericname.vm.network "private_network", type: "dhcp"
    genericname.vm.base_mac = "macaddress"

    genericname.vm.provider "virtualbox" do |vb|
      vb.name   = "genericname"
      vb.memory = 1024
      vb.cpus   = 1
    end

# Provisioning stuff
  end
end

Please note, if you are using Homestead or a different Vagrantfile format, we
may be unable to assist with your issue. Try to reproduce the issue using a
vanilla Vagrantfile first.

Expected behavior

Guest should mount shared folder

Actual behavior

Vagrant claims freebsd has no support for shared folders

Steps to reproduce

  1. Download FreeBSD vagrantbox from atlas
  2. Write vagrantfile
  3. vagrant up freebsdvm
guesfreebsd has-pr synced-foldergeneral

Most helpful comment

Hey all: I've made a pull request to address this issue and get synced folders working for BSD guests on VirtualBox: https://github.com/hashicorp/vagrant/pull/10717

Thanks! :heart: :tada:

All 12 comments

  • Nevermind, looks like this support was dropped at some point since I last tested it. Sorry!

I just tested virtualbox-ose-additions pkg in latest and quarterly branches, both support shared folder. Is it possible change it to not error out? Or is there any way to disable this behavior for testing the shared folder more?

@RainbowHackerHorse , do you want to reopen this issue?

If it's confirmed to work now and just needs to be fixed with Vagrant, of course :)

When the config.vm.synced_folder type explicitly specified in Vagrantfile as "vboxvfs", there is 'Internal error' (see below) finishes vagrant up command.

Vagrant

Vagrant 2.0.1

Host OS

Ubuntu 16.04.3 LTS x96_64

Host hypervisor

VirtualBox 5.2.4r119785

Guest OS

FreeBSD-11.1-RELEASE-p6 amd64

Guest addons

virtualbox-ose-additions-nox11-5.2.4 (via pkg)

Vagrantfile

Vagrant.configure(2) do |config|
  config.vm.define "www4" do |host|
    host.vm.box      = "vg-freebsd"
    host.vm.hostname = "www4"
    host.vm.network "private_network", ip: "10.0.0.103", virtualbox__intnet: true
    host.vm.synced_folder "/home/user/tmp/share", "/vagrant", type: "vboxvfs"
    host.vm.provider :virtualbox do |vb|
      vb.name = "www4"
    end 
  end 
end

Expected behavior

Guest should mount shared folder

Actual behavior

Vagrant issues the error:

/opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builtin/mixin_synced_folders.rb:137:in `block in synced_folders': Internal error. Report this as a bug. Invalid: vboxvfs (RuntimeError)
...

See vagrant_up_error.log attached.

Steps to reproduce

The similar to @RainbowHackerHorse mentioned above already, excepting the FreeBSD box was built from the 'official' FreeBSD VM image and the guest additions were installed via pkg command.

Troubleshooting

Once manually created for the guest, vagrant share folder has been mounted OK:

mount -t vboxvfs vagrant /vagrant/

If the synced folder disabled in the Vagrantfile:

config.vm.synced_folder ".", "/vagrant", disabled: true

the vagrant up www4 completes successfully.

Workaround

All the steps are Vagrantfile code between Vagrant.configure(2) do |config| and end.

  1. Disable default Vagrant synced folder:
config.vm.synced_folder ".", "/vagrant", disabled: true
  1. Make the synced folder 'manually':
host.vm.provider :virtualbox do |vb|
  vb.customize [ "sharedfolder", "add", :id, "--name", "vagrant", "--hostpath", "/home/user/tmp/share", "--automount" ]
end
  1. Mount the folder on provisioning and make it persistent:
host.vm.provision "shell", inline: <<-EOD
  mkdir -p -m 700 /vagrant
  egrep '^\s*vagrant' /etc/fstab ||\
    echo "vagrant /vagrant vboxvfs rw 0 0" >> /etc/fstab
  mount | egrep '^vagrant.+/vagrant.+' ||\
    mount /vagrant
EOD

I've been trying to get this to work on a osx host and FreeBSD 10.3 guest without any luck. I'm using a bento box, to which i've manually installed the latest virtualbox-ose-additions (overwriting the previous). But creating a synced folder with either config.vm.synced_folder or the manual steps from @vvvggg above, don't work. Is this something unique to FreeBSD 11 or am I misunderstanding something?

10.3 is EOL. Use 10.4 at minimum, though I can't confirm this will work on anything but 11.1-RELEASE right now.

workaround config provided by @vvvggg is working great for me with the bento FreeBSD 11.1 box.

config.vm.box = "bento/freebsd-11.1"

config.vm.provider "virtualbox" do |virtualbox|
    virtualbox.customize [ "sharedfolder", "add", :id, "--name", "vagrant", "--hostpath", "/Users/wouter/Projects/test"]
end

config.vm.provision "shell", inline: <<-EOD
  mkdir -p -m 700 /vagrant
  egrep '^\s*vagrant' /etc/fstab ||\
    echo "vagrant /vagrant vboxvfs rw 0 0" >> /etc/fstab
  mount | egrep '^vagrant.+/vagrant.+' ||\
    mount /vagrant
  EOD

Yup, same, works a charm, but only in a minimal use-case.

Sadly i'm finding that vboxfs can't really cope with my codebase. If I dump it into a mounted vboxvfs folder while the machine is off, then restart, it only transfers part of the codebase. There doesn't seem to be anything special about the folders it doesn't transfer (e.g there are no symlinks in them, and even then I've added that VBoxInternal2/SharedFoldersEnableSymlinksCreate 'hack' to be sure)

Secondly, scripts that run to bootstrap my dependencies kill the vboxvfs mount. I've got both NPM and Cpan deps to install. Even if I symlink both affected folders outside the mount, as suggested by so many online, if I perform any task on the guest that attempts to enter either folder it kills the ssh session, sometimes kills the box, and usually the mount stops responding properly until I reboot the guest.

Both these issues are well documented online, I'm not seeking a solution. Just a bit bummed that vboxvfs support isn't quite the silver bullet I had hoped after waiting so long for support for it in freebsd!

It would be nice to see this as it would resolve an issue where we have FreeBSD guests and users on a mix of OSX, Linux and Windows hosts trying to use the same Vagrantfile(s) ...

Hey all: I've made a pull request to address this issue and get synced folders working for BSD guests on VirtualBox: https://github.com/hashicorp/vagrant/pull/10717

Thanks! :heart: :tada:

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings