How To Use beadm to Upgrade FreeBSD installed in a ZFS Boot Environment, with minimal downtime

Setting Up A Jail

In order to update ports within the new boot environment before making it the live boot environment, it needs to be launched in a jail. the best way I have found to do this is to create a jail configuration file, and a few scripts within the /jails/devel directory that will handle all the work making this a simple step in the future as you rotate through various patch updates and keep restore points for port updates. The first file, is the /jails/devel/jail.conf file which is just a single jail definition in the format used by /etc/jail.conf.

# Define Development Jail
freebsd-zfs-devel {
  jid = 100;
  host.hostname = freebsd-zfs-devel.dweimer.me;
  ip4.addr = 192.168.5.37;
  interface = em0;
  path = /jails/devel/ROOT;
  allow.mount.devfs;
  mount.devfs;
  allow.sysvipc;
  exec.start = "/bin/sh /etc/rc";
  exec.stop = "/bin/sh /etc/rc.shutdown";
  exec.prestart = "/jails/devel/prestart.sh";
  exec.poststop = "/jails/devel/poststop.sh";
  exec.consolelog = "/jails/devel/console.log";
}

Note:  I am expecting that you are already familiar with the jail setup, the import part to note here is the jails name, and the prestart and poststop scripts, as those will be used in the following steps.

Note:  Make sure to change teh IP Address and Network Interface to one that matches your interface name, and IP subnet.

Its also a good idea to create a new etc/rc.conf file that will be used while the boot environment is booted within the jail. The scripts I have setup use /jails/devel/ROOT/etc/rc.conf.jail to replace the original boot environments rc.conf, in this case its just a blank file. In some of my setups I do include additional options in it for testing some services with alternate configuration paths.