FreeBSD (ez)jail howto

Table of Contents

Prepare the system
Create ezjail templates
Working with the jails

Create ezjail templates

by ross at 14:05:06 on February 23, 2013

Basejail

To work with ezjail you need a basejail, containing the part of the world that is shared between jails.

# ezjail-admin update -i -p

This will create /usr/jails/basejail with the ports tree using world in /usr/obj.

The command above will also create /usr/jails/newjail (a skeleton for every jail you create) and /usr/jails/flavors (directory holding preconfigured jail templates).

Newjail

Basically newjail is a flavour always applied.

# cp /etc/localtime newjail/etc/

Use host's timezone in jails.

vi /usr/jails/flavours/webserver/etc/resolv.conf

search local
nameserver 192.168.10.1

This will setup host system as nameserver for the jail. Replace local with your local DNS zone name.

Flavours

Flavours will be copied recursively over any new jail created with the ezjail-admin -f FLAVOUR command.

Let's create a simple flavour called webserver which we will use to create a couple of jails.

Flavour files will overwrite newjail files. If you need to modify a file in the flavour start by copying the file from newjail tree.

# cd /usr/jails
# mkdir -p flavours/webserver/etc
# cp newjail/etc/make.conf flavours/webserver/etc/

vi /usr/jails/flavours/webserver/etc/make.conf

WRKDIRPREFIX=           /var/ports
DISTDIR=                /var/ports/distfiles
PACKAGES=               /var/ports/packages
INDEXDIR=               /var/ports

.if ${.CURDIR:M*/www/apache22}
SUEXEC_DOCROOT=/
.endif

Add other the files you need to flavours/webserver.

 

Comments