The main reason, or the good reason to use jails instead of a VM is that i will be running inside jails/VM a FreeBSD version, and that makes it easier and less resource consuming using a jail than using a VM.
So i needed to learn a bit of FreeBSD Jails and how to go about on how to use them.
A very good place to start is the FreeBSD Handbook, and there you can find a chapter dedicated to Jails and Containers:
Chapter 17. Jails and Containers
In this chapter they will go over the basics and the types of jails you can create/use in FreeBSD and some of the requirements/restrictions of using the jail service, for example a strict requirement that the FreeBSD version inside the jail can not be newer than the version running in the host.
After reading the documentation and my plan about learning to set it up and running the jail and went to the simple approach of having a thick jail, which means i have a full working copy of a FreeBSD version running in the jail complete and independent of the FreeBSD version on the host with it is own base system, libs, executables and configuration files and as well an independent ports tree.
While a thick jail will use more resources, namely disk space, but in my case that is not an issue for the moment.
Following the instructions is very straight forward, and in my case the FreeBSD contains a ZFS volume i opted to store all the related jail files and containers in a set of datasets that i have linked into the /usr/local/jails directory for easy management of storage needed.
As per the instructions i downloaded the 14.2 release userland file, and extracted it to the location where the container will be kept.
With this done, then the next step was to create a configuration file, which i just copied the template that is present in the handbook chapter and made the minor modifications needed for my own system. Changed the name to "jail", assigned an IP address inside my home network and changed the interface name to reflect the one present in my FreeBSD which is "re0".
And also i made sure the jails service can be started manually and later on, after i am confortable with the installations and configuration i have done, start the jails service and the configured jails will also start on boot, by executing the following commands:
# sysrc jail_enable="YES"
# sysrc jail_parallel_start="YES"
The first command enables the jails in FreeBSD and the second command makes sure that any configured jail will be started when FreeBSD boots.
With all the basic stuff done and configured it was time to start/boot the jail and see what we got. That was simply done by issuing the command:
# service jail start jail
Starting jails: jail.
#
And it seems the jail is running, and you can check the output from the console that has been redirect to, based on the configuration template:
exec.consolelog = "/var/log/jail_console_${name}.log";
Looking into the log file i can see that the system has started and get the normal output of a FreeBSD system starting up.
To my surprise, and will have to say thanks to the excellent documentation in the handbook, the FreeBSD jail seems to be running as expected, and now it is time to actual start configuring it and installing the needed software for what i want to do with it.
That will be the content for the next article. :-)