Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 468:3108ce603fa1
Add usage examples for managing thin jails with the ftjail commands into the manual page of ftjail
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 21 Aug 2024 12:58:35 +0200 |
| parents | 6ecd16725818 |
| children | aae67d3011b4 |
| files | docs/man/man8/ftjail.rst |
| diffstat | 1 files changed, 106 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/man/man8/ftjail.rst Fri Jun 14 09:40:04 2024 +0200 +++ b/docs/man/man8/ftjail.rst Wed Aug 21 12:58:35 2024 +0200 @@ -84,3 +84,109 @@ ----------- All environment variables that affect :command:`zfs` are effective also. + + +Examples +-------- + +Prepare the containers for the template datasets +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Container for templates:: + + zfs create -o canmount=off -o mountpoint=/jail/ttmpl zpool/jail/ttmpl + +Sub-container for all read-only bases:: + + zfs create -o canmount=off zpool/jail/ttmpl/base-ro + +Sub-container for all read-write volumes:: + + zfs create -o canmount=off zpool/jail/ttmpl/skel-rw + + +Create a new complete template for a FreeBSD distribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Create new template datasets and populate them from a distribution archive. +The example is for FreeBSD 13.3-RELEASE:: + + # prepare empty datasets + ftjail datasets-tmpl -P zpool/jail/ttmpl/base-ro zpool/jail/ttmpl/skel-rw 13.3-RELEASE + + # + # Here you can adjust some properties (``canmount``) or create some additional + # datasets manually. + # + + # mount at a temporary mountpoint + mkdir /var/tmp/13.3 + ftjail mount-tmpl -P zpool/jail/ttmpl/base-ro/13.3-RELEASE zpool/jail/ttmpl/skel-rw/13.3-RELEASE /var/tmp/13.3 + + # populate the contents from the distribution archive + ftjail populate-tmpl -P /var/tmp/13.3 base-13.3-RELEASE.txz + + # If the kernel is wanted also then extract it like this + ftjail populate-tmpl -P -b /var/tmp/13.3 base-13.3-RELEASE.txt kernel-13.3-RELEASE.txz + +Make a named snapshot named "base" for the original:: + + ftjail snapshot-tmpl zpool/jail/ttmpl/base-ro/13.3-RELEASE zpool/jail/ttmpl/skel-rw/13.3-RELEASE base + +Also prepare the :command:`etcupdate`:: + + ftjail build-etcupdate-current-tmpl /var/tmp/13.3 etcupdate-current-13.3@base.tbz + +Update to the current patch level and tag accordingly (e.g. "p5"):: + + # Update + freebsd-update -b /var/tmp/13.3 -d /var/tmp/13.3/var/db/freebsd-update/ --currently-running 13.3-RELEASE fetch + freebsd-update -b /var/tmp/13.3 -d /var/tmp/13.3/var/db/freebsd-update/ --currently-running 13.3-RELEASE install + + # Snapshot + ftjail snapshot-tmpl zpool/jail/ttmpl/base-ro/13.3-RELEASE zpool/jail/ttmpl/skel-rw/13.3-RELEASE p5 + + # Do not forget to prepare for etcupdate + ftjail build-etcupdate-current-tmpl /var/tmp/13.3 etcupdate-current-13.3@p5.tbz + +Unmounten:: + + ftjail umount-tmpl zpool/jail/ttmpl/base-ro/13.3-RELEASE zpool/jail/ttmpl/skel-rw/13.3-RELEASE + + +Container and Common Location for instantiated Thin Jails +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +All thin jails are located at :file:`/jail/TROOT`:: + + zfs create -o mountpoint=/jail/TROOT zpool/jail/TROOT + +Create the variable datasets (read-write) with the same mountpoint as above:: + + zfs create -o canmount=off -o mountpoint=/jail/TROOT zpool/jail/TVAR + + +Creation of a real Thin Jail +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Clone the read-only root filesystem base:: + + zfs clone -o readonly=on zpool/jail/ttmpl/base-ro/13.3-RELEASE@p5 zpool/jail/TROOT/build13 + +If you want some additional directory (e.g. for :file:`/srv` et al.) do this +instead:: + + zfs clone -o readonly=off zpool/jail/ttmpl/base-ro/13.3-RELEASE@p5 zpool/jail/TROOT/build13 + # change before making it read-only + mkdir /jail/TROOT/build13/srv + zfs set readonly=on zpool/jail/TROOT/build13 + +Copy -- not clone -- the variable parts:: + + ftjail copy-skel -P zpool/jail/ttmpl/skel-rw/13.3-RELEASE p5 zpool/jail/TVAR/build13 + +Configure some important parts (as in "normal" jails):: + + mount -t devfs devfs /jail/TROOT/build13/dev + fjail configure /jail/TROOT/build13 + umount /jail/TROOT/build13/dev
