FreeNAS® supports the ability to add custom templates to the Templates drop-down menu described in Table 13.2.1.

To create a custom template, first install the desired operating system and configure it as needed. The installation can be either to an existing jail or on another system.

Next, create an mtree specification using this command, replacing /path/to/jail with the actual path to the jail:

mtree -c -p /path/to/jail -k sha256digest > file.mtree

After configuration is complete, create a tarball of the entire operating system to be used as a template. This tarball needs to be compressed with gzip and end in a .tgz extension. Be careful when creating the tarball as it is possible to end up in a recursive loop. In other words, the resulting tarball must be saved outside of the operating system being tarballed, such as to an external USB drive or network share. Alternately, create a temporary directory within the operating system and use the –exclude switch to tar to exclude this directory from the tarball. The exact tar command to use will vary, depending upon the operating system being used to create the tarball.

Save the generated .mtree and .tgz files to either an FTP share or an HTTP server. The FTP or HTTP URL is needed to add the template to the list of available templates.

To add the template, click Jails Templates Add Jail Templates which opens the screen shown in Figure 13.3.1.