pascal jungblut posts

Vagrant with FreeBSD as guest OS (update)

When you’re working with Vagrant and your production servers are running FreeBSD, chances are that you also want to use FreeBSD as the Vagrant guest OS so the behaviour is consistent. The combination will not work out-of-the-box because FreeBSD doesn’t support the standard synced folder method Vagrant uses. So you need to switch to NFS sharing which needs a host-only (:private_network) network. Once you enable that, Vagrant cannot connect anymore to the virtual machine over SSH and it will look as if the machine halted.

See update below! There is a nice workaround to use two virtual network interfaces. Here is a minimal Vagrantfile that works with FreeBSD 9.1:

Vagrant.configure("2") do |config|
  config.vm.box = "freebsd91"
  config.vm.box_url = "https://s3.amazonaws.com/vagrant_boxen/freebsd_amd64_zfs.box"

  # Private network for NFS
  config.vm.network :private_network, ip: "10.0.0.2"

  # configure the NICs
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
    vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
  end
  
  # use NFS for the synced folder
  config.vm.synced_folder ".", "/vagrant", :nfs => true
end

Update October 26, 2013

Petar Radošević published a FreeBSD 9.2 base box for Virtual Box with a nice, optimized Vagrantfile. The repository also includes a very handy guide on how to build your own Virtual Box image from the FreeBSD ISO.