freebsd:jails
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| freebsd:jails [2020/09/28 08:23] – sleepy | freebsd:jails [2025/07/07 23:10] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 19: | Line 19: | ||
| #BASE { | #BASE { | ||
| # | # | ||
| - | # | + | # |
| # | # | ||
| ---- | ---- | ||
| + | |||
| + | |||
| + | |||
| ====== Create zfs jail base ====== | ====== Create zfs jail base ====== | ||
| + | ===== Create from source ===== | ||
| <code bash> | <code bash> | ||
| - | zfs create -o quota=30G zroot/ | + | zfs create -o quota=30G zroot/ |
| cd /usr/src | cd /usr/src | ||
| - | make installworld DESTDIR=/ | + | make installworld DESTDIR=/ |
| - | make distribution DESTDIR=/ | + | make distribution DESTDIR=/ |
| </ | </ | ||
| + | |||
| + | ===== Create from release tarball ===== | ||
| + | * grab the **base** and **lib32** tarballs for your FreeBSD version <code bash> | ||
| + | fetch https:// | ||
| + | * extract snapshot tarballs to jail path <code bash>tar -xf base.txz -C /jails/BASE | ||
| + | tar -xf lib32.txz -C / | ||
| + | |||
| ---- | ---- | ||
| - | ===== Configure zfs jail base ===== | + | |
| + | ====== Configure zfs jail base ====== | ||
| <code bash> | <code bash> | ||
| - | touch /jails/BASE_12.2-STABLE/etc/fstab | + | touch /jails/BASE/etc/fstab /jails/BASE/etc/rc.conf |
| - | cp /etc/localtime | + | mkdir -p / |
| - | cp /etc/resolv.conf /jails/BASE_12.2-STABLE/etc/ | + | cp /usr/local/etc/pkg/ |
| - | touch /jails/BASE_12.2-STABLE/etc/rc.conf | + | cp / |
| - | echo ' | + | cp /etc/resolv.conf / |
| - | echo ' | + | echo ' |
| - | echo ' | + | echo ' |
| + | echo ' | ||
| </ | </ | ||
| - | * jails don't use fstab, but some programs need it <code bash> | + | * jails don't use fstab, but some programs need it <code bash> |
| - | * jails will probably be in same timezone as host <code bash>cp / | + | * jails will probably be in same timezone as host <code bash>cp / |
| - | * don't need to configure dns servers <code bash>cp / | + | * don't need to configure dns servers <code bash>cp / |
| - | * don't need sendmail <code bash> | + | * don't need sendmail <code bash> |
| - | * no need to run ntpd since jail cannot change time <code bash> | + | * no need to run ntpd since jail cannot change time <code bash> |
| - | * enable sshd <code bash> | + | * enable sshd <code bash> |
| ---- | ---- | ||
| Line 51: | Line 64: | ||
| ==== install typical packages, add user, install dotfiles, copy keys.==== | ==== install typical packages, add user, install dotfiles, copy keys.==== | ||
| <cli green uppercase> | <cli green uppercase> | ||
| - | jexec -l BASE pkg install nano zsh git-lite python37 py37-pip | + | pkg -j BASE install nano zsh git-lite python37 py37-pip |
| jexec -l BASE adduser | jexec -l BASE adduser | ||
| jexec -l -U sleepy BASE git clone https:// | jexec -l -U sleepy BASE git clone https:// | ||
| Line 58: | Line 71: | ||
| jexec -l BASE chsh -s zsh | jexec -l BASE chsh -s zsh | ||
| jexec -l -u sleepy BASE mkdir / | jexec -l -u sleepy BASE mkdir / | ||
| - | cp ~sleepy/ | + | cp ~sleepy/ |
| jexec -l BASE chown -R sleepy: | jexec -l BASE chown -R sleepy: | ||
| jexec -l BASE chmod 700 / | jexec -l BASE chmod 700 / | ||
| Line 66: | Line 79: | ||
| Snapshot the BASE jail | Snapshot the BASE jail | ||
| - | <code bash>zfs snapshot zroot/ | + | <code bash>zfs snapshot zroot/ |
| ---- | ---- | ||
| ====== Create jail ====== | ====== Create jail ====== | ||
| - | * create new jail dataset <code bash>zfs clone zroot/ | + | * create new jail dataset <code bash>zfs clone zroot/ |
| * add entry to **/ | * add entry to **/ | ||
| python { | python { | ||
| Line 76: | Line 89: | ||
| }</ | }</ | ||
| * add entry to **/ | * add entry to **/ | ||
| - | |||
| ---- | ---- | ||
| + | ====== Updating jails ====== | ||
| + | ===== using source ===== | ||
| + | assuming you have already built and installed world and kernel. Stop the running jail(s) first. | ||
| + | < | ||
| + | make installworld DESTDIR=/ | ||
| + | mergemaster -iFU -D /jails/path | ||
| + | </ | ||
| + | ==== jails_update.sh ==== | ||
| + | Script to automate the updates, just make sure to update the jails paths. | ||
| + | <code bash jails_update.sh> | ||
| + | jails="/ | ||
| + | cd /usr/src | ||
| + | |||
| + | for jail in $jails | ||
| + | do | ||
| + | make installworld DESTDIR=$jail | ||
| + | mergemaster -iFU -D $jail | ||
| + | done | ||
| + | </ | ||
| + | |||
| + | ===== using freebsd-update binaries ===== | ||
| + | <code bash> | ||
| + | freebsd-update -b /jails/path fetch | ||
| + | freebsd-update -b /jails/path install | ||
| + | </ | ||
| + | ---- | ||
| ====== To Do ====== | ====== To Do ====== | ||
| - | * create ZFS dataset with 20% reserve quota | + | * create ZFS dataset with 20% reserve quota <code bash>zfs create -o quota=300G -o mountpoint=/ |
| - | * **zfs create -o quota=300G -o mountpoint=/ | + | |
| + | echo $jail</ | ||
| + | | ||
| + | * need to create alias for jail ip on hosts network interface during jail creation. | ||
| + | * using '' | ||
| + | * permanent using '' | ||
freebsd/jails.1601281415.txt.gz · Last modified: (external edit)
