Jails

Creating a jail

First the jail directory needs to be crated

mkdir -p /jails/test

After, we can use pacman to install base packages , but first some directories that are needed by pacman inside the jail need to be created

mkdir -p /jails/test/var/lib/pacman/local
mkdir -p /jails/test/var/lib/pacman/sync

Using pacman to install the base

sudo pacman --config /etc/pacman.conf --cachedir /var/cache/pacman/pkg/ -r /jails/test -Sy 
sudo pacman --config /etc/pacman.conf --cachedir /var/cache/pacman/pkg/ -r /jails/test -S freebsd-kernel freebsd-world pacman sudo

Config the jail.conf and rc.conf to enable jail startup

sudo cat > /etc/jail.conf <<EOF
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.clean;
mount.devfs;

test {
        path = /jails/test;
        allow.mount;
        mount;
        host.hostname = test;
        ip4.addr = 192.168.0.10;
        interface = hn0; # the main network interface(could be em0,etc) ip is added as alias
        allow.raw_sockets; # allow ping from jail (also required by some other packages)
        }
EOF
sysrc jail_conf="YES"
to enable the jails

Now in order to have the jail started the host needs to be restarted, or errors generated by rc will not allow starting of jail.