FreeBSD/jails.md

Mon, 28 Aug 2017 09:04:46 +0200

author
David Demelier <markand@malikania.fr>
date
Mon, 28 Aug 2017 09:04:46 +0200
changeset 5
435b53af6b96
parent 3
1fcfc84724ca
child 7
c32b5c002aad
permissions
-rw-r--r--

FreeBSD: fix incorrect jail naming in poudriere.md

2
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 FreeBSD jails howto
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 ===================
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
3
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 This guide will let you create your own jails for FreeBSD.
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
5
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 In this guide, we will build jails from sources.
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
7
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 What are jails?
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 ===============
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
10
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 Jails are confined environments that run on host kernels. They are similar to
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 chroots but have much more features.
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
13
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 Fetching source tree
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 ====================
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
16
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 In this guide we will assume that we are running FreeBSD 11.1-RELEASE, to fetch
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
18 the source tree, you need this following URL:
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
19
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
20 svn://svn.FreeBSD.org/base/releng/<VERSION>
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
21
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
22 In our case:
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
23
3
1fcfc84724ca FreeBSD: use svnlite instead of svn in jails.md
David Demelier <markand@malikania.fr>
parents: 2
diff changeset
24 svnlite co svn://svn.FreeBSD.org/base/releng/11.1 /usr/src
2
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
25
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
26 Customizing the build
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
27 =====================
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
28
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
29 The source tree can be built with and without a lot of options. This is tweaked
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
30 in the `src.conf(5)` file.
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
31
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
32 Removing options will let you build lighter jails, for example I use the
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
33 following one:
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
34
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 # /etc/src.conf
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
36 WITHOUT_APM=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
37 WITHOUT_AMD=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
38 WITHOUT_AUTHPF=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 WITHOUT_BLUETOOTH=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 WITHOUT_CTM=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 WITHOUT_FLOPPY=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
42 WITHOUT_GAMES=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
43 WITHOUT_IPFILTER=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
44 WITHOUT_IPFW=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
45 WITHOUT_IPX=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
46 WITHOUT_NDIS=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
47 WITHOUT_OBJC=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
48 WITHOUT_PORTSNAP=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
49 WITHOUT_PPP=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
50 WITHOUT_PROFILE=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 WITHOUT_RESCUE=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
52 WITHOUT_WIRELESS=yes
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
53
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
54 See the manual page to know what they control.
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
55
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
56 Build the source
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
57 ================
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
58
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 To build the source, use these commands:
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
60
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
61 cd /usr/src
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
62 make buildworld
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
63
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
64 Note: this only builds the source tree and does not install anything.
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
65
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
66 The jail template
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 =================
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
68
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
69 To avoid doing the same step again and again each time we build a jail, we will
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
70 create a template one that we will clone.
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
71
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
72 We will create that jail in **/jails/template** dataset.
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
73
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
74 zfs create zroot/jails
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
75 zfs create zroot/jails/template
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
76
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
77 And now install everything in that template directory.
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
78
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
79 cd /usr/src
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
80 make DESTDIR=/jails/template installworld
68e126f0eed0 FreeBSD: add beginning of jails.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
81 make DESTDIR=/jails/template distribution

mercurial