I am trying to create my first Jail, my host system is FreeBSD 13.2 and uses UFS. I am aiming to create thin jails for my workstation as my disk space is limited.
It is my understanding that Chapter 17 of the Handbook, that covers the manual creation of Jails covers this case.
I include the steps I follow mirroring the handbook, including some listing of the files and the error I get.
I do also have some questions regarding the procedure:
a) At step 3, when the handbook creates the template using 13.2-RELEASE-base, what is the purpose of the template folder (/usr/local/jails/templates/13.2-RELEASE-base/)?
b) At step 3, what is the difference between /usr/local/jails/templates/13.2-RELEASE-base and /usr/local/jails/templates/13.2-RELEASE-skeleton? what are the purpose of each one?
c) What is the fstab file actually doing? (in this particular context, what are we mounting and why).
1. Create the folder structure
2. Create the configuration file
3. Create a Thin Jail using NullFS
4. Create the actual jail
It is my understanding that the actual Jail is under containers.
At this point the jail shall be created and can be started using:
I was recommended to create dev at cd /usr/local/jails/templates/13.2-RELEASE-base/, but the jail could not starte.
It is my understanding that Chapter 17 of the Handbook, that covers the manual creation of Jails covers this case.
I include the steps I follow mirroring the handbook, including some listing of the files and the error I get.
I do also have some questions regarding the procedure:
a) At step 3, when the handbook creates the template using 13.2-RELEASE-base, what is the purpose of the template folder (/usr/local/jails/templates/13.2-RELEASE-base/)?
b) At step 3, what is the difference between /usr/local/jails/templates/13.2-RELEASE-base and /usr/local/jails/templates/13.2-RELEASE-skeleton? what are the purpose of each one?
c) What is the fstab file actually doing? (in this particular context, what are we mounting and why).
1. Create the folder structure
Code:
# mkdir /usr/local/jails/
# mkdir /usr/local/jails/media
# mkdir /usr/local/jails/templates
# mkdir /usr/local/jails/containers
Code:
# vim /etc/jail.conf.d/thinjail.conf
thinjail {
# STARTUP/LOGGING
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.consolelog = "/var/log/jail_console_${name}.log";
# PERMISSIONS
allow.raw_sockets;
exec.clean;
mount.devfs;
# HOSTNAME/PATH
host.hostname = "${name}";
path = "/usr/local/jails/containers/thinjail";
# NETWORK
ip4.addr = 192.168.178.202;
interface = em0;
}
3. Create a Thin Jail using NullFS
Code:
# mkdir /usr/local/jails/templates/13.2-RELEASE-base
# fetch https://download.freebsd.org/ftp/releases/amd64/amd64/13.2-RELEASE/base.txz -o /usr/local/jails/media/13.2-RELEASE-base.txz
# tar -xf /usr/local/jails/media/13.2-RELEASE-base.txz -C /usr/local/jails/templates/13.2-RELEASE-base --unlink
# cp /etc/resolv.conf /usr/local/jails/templates/13.2-RELEASE-base/etc/resolv.conf
# cp /etc/localtime /usr/local/jails/templates/13.2-RELEASE-base/etc/localtime
# freebsd-update -b /usr/local/jails/templates/13.2-RELEASE-base/ fetch install
Code:
# mkdir /usr/local/jails/templates/13.2-RELEASE-skeleton
# mkdir -p /usr/local/jails/templates/13.2-RELEASE-skeleton/home
# mkdir -p /usr/local/jails/templates/13.2-RELEASE-skeleton/usr
# mv /usr/local/jails/templates/13.2-RELEASE-base/etc /usr/local/jails/templates/13.2-RELEASE-skeleton/etc
# mv /usr/local/jails/templates/13.2-RELEASE-base/usr/local /usr/local/jails/templates/13.2-RELEASE-skeleton/usr/local
# mv /usr/local/jails/templates/13.2-RELEASE-base/tmp /usr/local/jails/templates/13.2-RELEASE-skeleton/tmp
# mv /usr/local/jails/templates/13.2-RELEASE-base/var /usr/local/jails/templates/13.2-RELEASE-skeleton/var
# mv /usr/local/jails/templates/13.2-RELEASE-base/root /usr/local/jails/templates/13.2-RELEASE-skeleton/root
# cd /usr/local/jails/templates/13.2-RELEASE-base/
# mkdir skeleton
# ln -s skeleton/etc etc
# ln -s skeleton/home home
# ln -s skeleton/root root
# ln -s skeleton/usr/local usr/local
# ln -s skeleton/tmp tmp
# ln -s skeleton/var var
4. Create the actual jail
It is my understanding that the actual Jail is under containers.
Code:
# mkdir /usr/local/jails/containers/thinjail
# cp -R /usr/local/jails/templates/13.2-RELEASE-skeleton /usr/local/jails/containers/thinjail
# mkdir -p /usr/local/jails/thinjail-nullfs-base
# vim /etc/jail.conf.d/thinjail.conf
thinjail {
# STARTUP/LOGGING
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.consolelog = "/var/log/jail_console_${name}.log";
# PERMISSIONS
allow.raw_sockets;
exec.clean;
mount.devfs;
# HOSTNAME/PATH
host.hostname = "${name}";
path = "/usr/local/jails/containers/thinjail";
# NETWORK
ip4.addr = 192.168.178.202;
interface = em0;
# MOUNT
mount.fstab = "/usr/local/jails/thinjail-nullfs-base.fstab";
}
# vim /usr/local/jails/thinjail-nullfs-base.fstab
/usr/local/jails/templates/13.2-RELEASE-base /usr/local/jails/thinjail-nullfs-base/ nullfs ro 0 0
/usr/local/jails/containers/thinjail /usr/local/jails/thinjail-nullfs-base/skeleton nullfs rw 0 0
At this point the jail shall be created and can be started using:
Code:
# service jail onestart thinjail
Starting jails: cannot start jail "thinjail":
jail: thinjail: mount.devfs: /usr/local/jails/containers/thinjail/dev: No such file or directory
.
I was recommended to create dev at cd /usr/local/jails/templates/13.2-RELEASE-base/, but the jail could not starte.