Using iocage on Freenas

Since the old jail system on Freenas is soon to be removed, they want users to migrate to iocage instead.

You can only administrate iocage jails via the new (beta) Web UI, with limited functionality however.

Here’s a quick reference on how to create a new jail, add network and mount a dataset in it.

Before I started I created a test-jail in the new Web UI, which downloaded the template for FreeBSD 11.1.

After that has been done (the test jail can be removed) you can run the following commands via the CLI.

Create the Jail:
iocage create -r 11.1-RELEASE -n '[jailname]' (ex. iocage create -r 11.1-RELEASE -n 'backup')

Set IP address for the jail:
iocage set ip4_addr='[interface]|[ipaddress]/24' '[jailname]' (ex. iocage set ip4_addr='lagg0|192.168.11.28/24' backup)

Add a dataset to the jail:
iocage fstab -a [jailname] /mnt/Storage/[dataset] (ex. iocage fstab -a backup /mnt/Storage/Snapshots)
iocage fstab -e [jailname] (change ro to rw in fstab if you want the dataset writable)

Create the folder in the jail for the dataset:
mkdir -p /mnt/Storage/iocage/jails/[jailname]/root/mnt/Storage/[dataset] (ex. mkdir -p /mnt/Storage/iocage/jails/backup/root/mnt/Storage/Snapshots)

Do take note that the mount or jailname should Not have any spaces in the name, if there are spaces in the name the mount/fstab command does not work because nullfs does not support spaces at this moment.

You can now start the jail via the new interface, or via CLI with the command:

iocage start [jailname]