---
agentTools:
  projectIndex: https://docs.project-fifo.net/llms.txt
---

# FreeBSD

[block:callout]
{
  "type": "danger",
  "title": "backwards compatibility",
  "body": "Due to problems we encountered with the approach taken in 0.9.2 it will change drastically with 0.9.3. The changes are so far-reaching FiFo 0.9.3 will not recognize jails created with 0.9.2!"
}
[/block]

Project-FiFo provides experimental support for BSD jails on FreeBSD.

At this point, FiFo depends on FreeBSD-11 +, RCTL, and vnet support.

Many of the steps below are FreeBSD centric, and we highly recommend to contact the FreeBSD community if you have problems or trouble with them as they are a lot more qualified to answer questions regarding BSD specific topics then we are.

[block:callout]
{
  "type": "warning",
  "title": "Be safe",
  "body": "As always: \n* make backups\n* don't use experimental features on critical systems"
}
[/block]

# Getting Started

## compile a kernel with VIMAGE

[block:code]
{
  "codes": [
    {
      "code": "# exact kernel version does not matter!\nfetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/`freebsd-version -k`/src.txz -o /tmp/src.txz\ntar -C / -xzf /tmp/src.txz\ncd /usr/src/sys/amd64/conf\ncat > FIFOKERNEL <<EOL\ninclude GENERIC\nident FIFOKERNEL\n\noptions         VIMAGE # VNET/Vimage support\noptions         RACCT  # Resource containers\noptions         RCTL   # same as above\nEOL\n\ncd /usr/src\nmake -j`sysctl -n hw.ncpu` buildkernel KERNCONF=FIFOKERNEL\nmake -j`sysctl -n hw.ncpu` installkernel KERNCONF=FIFOKERNEL\n\n## enable required modules and enable rcct\ncat <<EOF >> /boot/loader.conf\nlinux64_load=\"YES\"\nlinux_load=\"YES\"\nfdescfs_load=\"YES\"\nlinprocfs_load=\"YES\"\nlinsysfs_load=\"YES\"\ntmpfs_load=\"YES\"\nmac_portacl_load=\"YES\"\nkern.racct.enable=1\nEOF\n\nreboot\n",
      "language": "shell"
    }
  ]
}
[/block]

## Setting up some ZFS

All FiFo components follow a simple rule: mutable data is stored in `/data/<service>` best practice is to set up a ZFS filesystem for each of them:

[block:code]
{
  "codes": [
    {
      "code": "zfs create zroot/data\nzfs set mountpoint=/data zroot/data\nzfs create zroot/data/sniffle\nzfs create zroot/data/snarl\nzfs create zroot/data/howl\nzfs create zroot/jails\nzfs set mountpoint=/zroot/jails zroot/jails",
      "language": "shell"
    }
  ]
}
[/block]

## Add package repository

We provide packages for all FiFo components to add the repository please run:

[block:code]
{
  "codes": [
    {
      "code": "mkdir -p /usr/local/etc/pkg/repos\ncat <<EOF > /usr/local/etc/pkg/repos/ProjectFiFo.conf\nProjectFiFo: {\n  url: \"pkg+https://freebsd.project-fifo.net/rel/amd64/11.0\",\n  mirror_type: \"srv\",\n  enabled: yes\n}\nEOF\npkg update",
      "language": "shell"
    }
  ]
}
[/block]

## Install core components

FiFo has two sets of components, the management system itself and what needs to be installed on each hypervisor, so lets install the hypervisor

[block:code]
{
  "codes": [
    {
      "code": "pkg install vmadm chunter zlogin\n\ncat  <<EOF >> /etc/rc.conf\nzlogin_enable=\"YES\"\nchunter_enable=\"YES\"\nvmadm_enable=\"YES\"\nEOF\n\nservice zlogin start\nservice chunter start",
      "language": "shell"
    }
  ]
}
[/block]

Note vmadm does not have to be started, it's run as a service to automatically boot jails on system startup that have the `autoboot` attribute set to true.

## install management suite

The management components do not have to live on every hypervisor instead it's enough to install them on one, however for production use where uptime mattes it's recommended to run a cluster for at least 5 nodes.

This component can be run both in a jail on the host.

[block:code]
{
  "codes": [
    {
      "code": "pkg install fifo-sniffle fifo-snarl fifo-howl fifo-cerberus\n\ncat  <<EOF >> /etc/rc.conf\nsniffle_enable=\"YES\"\nsnarl_enable=\"YES\"\nhowl_enable=\"YES\"\nEOF",
      "language": "shell"
    }
  ]
}
[/block]

The packages will print some more required steps like allowing howl to use privileged ports like `80`/`443`.

[block:code]
{
  "codes": [
    {
      "code": "\nkldload  mac_portacl\n\ncat  <<EOF >> /etc/sysctl.conf\nsecurity.mac.portacl.enabled=1\nsecurity.mac.portacl.rules=uid:1004:tcp:80,uid:1004:tcp:443\nEOF",
      "language": "shell"
    }
  ]
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "service sniffle start\nservice snarl start\nservice howl start",
      "language": "text"
    }
  ]
}
[/block]

Cerberus isn't a separate service but rather a set of static files for the UI, so does not need to be started.

## Networking

vmadm requires a bridge interface to allow VNET interfaces to attach to. If you have multiple networks you can have multiple bridge interfaces. The mapping of a network to its bridge is configured in the vmadm config file.

## Setting up the components

[block:callout]
{
  "type": "info",
  "title": "IP addresses",
  "body": "Please make sure that for all components, when editing the config file you chan change the IP address to the interface you want to use to communicate over."
}
[/block]

### vmadm

FiFo provides a vmadm clone for FreeBSD that works with jails. It is API compatible with the SmartOS vmadm in the sense that it provides a subset of its functionality and translates those to native jail equivalents

You might want to configure the config file `/usr/local/etc/vmadm.toml` and enable vmadm as a startup services.

Both the pool and networks section might need changing

[block:code]
{
  "codes": [
    {
      "code": "pool = \"zroot/jails\"\n[networks]\nadmin = \"bridge0\"",
      "language": "toml"
    }
  ]
}
[/block]

[block:callout]
{
  "type": "danger",
  "title": "FreeBSD and bridges",
  "body": "When using a bridge interface it is important to disable some of the hardware features of the NIC. If this is not done FreeBSD will take them down itself for the first VNET interface is added possibly causing a connection loss for multiple seconds. To avoid this add the following flags `-tso -lro -rxcsum -txcsum -rxcsum6 -txcsum6` to the rc.conf bringing up your interface for example:\n\n`ifconfig_em0=\"DHCP -tso -lro -rxcsum -txcsum -rxcsum6 -txcsum6\"`"
}
[/block]

## Initial config

Otherwise please follow tine [Installing FiFo](https://docs.project-fifo.net/docs/installing-fifo) guide for the setup.

## LeoFS

FiFo uses LeoFS as a local dataset cache, we do not provide own FreeBSD packages for it as they provide it themselfs: <http://leo-project.net/>

An alternative is to disable LeoFS