Using ZFS BE’s with opnsense

The OPNsense installer supports ZFS out of the box. By default, it names your pool zroot. To confirm the name of your pool, from a CLI on your OPNsense box type zpool list. Note the name of your pool, as you will need it to setup the scrub and trim cronjobs.

We need to create 2 cronjobs in the OPNsense GUI for scrubbing and trimming the drive. You probably want these to run monthly, late at night or early in the morning a day apart. In opnsense goto SYSTEM –> SETTINGS –> CRON. Add two cronjobs, one for the ZFS Pool Scrub command and the other for ZFS Pool Trim command (both are pre-defined commands in the drop down). Make sure to enter your pool name in the parameters field for both jobs.

For OPNsense, it probably makes more sense to use “boot environments” instead of snapshots. From an OPNsense CLI you can type bectl list to get a list of the current boot environments. N designates an active now status and R designates the boot environment will be active on reboot. To create backup prior to upgrading from the CLI (Note that im using version numbers 23.1 and 23.7 for naming, but you can use anything you want to name your BE’s):

  • bectl create 23.1 – This creates a BE named for the current installed working version
  • bectl rename default 23.7 – Rename our current BE to our target upgrade version
  • From the web GUI upgrade OPNsense
  • To revert from the CLI simply bectl activate 23.1 and reboot.
  • To remove the BE after successful upgrade, bectl destroy 23.1

Leave a comment