From PacBSD Wiki
Revision as of 18:12, 16 September 2014 by Claud (talk | contribs) (Creating a jail)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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";

test {
        path = /jails/test;
        host.hostname = test;
        ip4.addr =;
        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)
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.