4 :font-family: sans-serif
6 This is the script collection for a bespoke "subhost" platform for
7 running sandboxed services directly on the infrastructure hosts rather
8 than within virtual machines (VM).
13 The +pretend-boot+ script runs a subhost almost as if booted in a
14 virtual machine, except of course, that it really is merely an
15 "unshared sandboxing" executed by the the host kernel.
19 # ./pretend-boot mysubhost
22 +pretend-boot+ sets up the +/opt/sub/mysubhost/live+ directory that it
23 uses as root filesystem mount point. It requires the variables DISKS
24 and BRIDGES to be set, either as environment variables, or via a
25 configuration file that it by default expects to find at
26 +/opt/sub/mysubhost/config+ That +config+ would be a textfile, or in
27 fact a +bash+ source file, that should set the variables +DISKS+ and
28 +BRIDGES+ for running the subhost.
31 **The +DISKS+ variable** is an array declaring the disks in terms the
32 partitions to mount. Each array element has three parts with ":"
35 1. the device node name to use in the subhost
36 2. the partition index
37 3. the disk image file on the host
39 The very first element of +DISKS+ is the subhost root filesystem,
40 which gets loop-mounted during the "pretend boot".
46 DISKS=( vda:1:/disks/disk1.raw vdb:1:/disks/disk2.raw )
50 **The +BRIDGES+ variable** is an array declaring the network interfaces in
51 terms of their host appearance. Each array element has two parts with
54 1. the host bridge to link up with
55 2. the subhost interface's MAC address
61 BRIDGES=( homenet:06:a7:dd:b4:02:f2 )
64 Obviously the first ":" separates the bridge name from the MAC
65 address, which in itself includes 5 (more) ":" characters.
71 The +subhost-init+ script is copied into the subhost root filesystem,
72 and it first performs the rudimentary pre-pivot tasks (mounting "proc"
73 etc.), the runs rcS and rc2 before entering into a plain wait for
74 anything to be written to +/run/initctl+ which works as an immediate
75 +poweroff+ for the subhost.
84 The +control+ script is an alternative subhost run script used for
85 experimentation and debugging.
87 It sets up the subhosts fully within the $SUBHOST directory tree,
88 originally +/opt/subhost+, and each subhost system is represented
89 there as its own directory tree whose top level contains the
92 * +config+ is a bash include file that declares the subhost setup for
95 * +live+ is the root of the subhost filesystem when activated. It
96 gets set up either as an +rbind+ mount of the subhost +root+ or as an
97 +overlay+ mount placing the subhost +root+ over a common, read-only
100 * +root+ is the directory that contains the subhost filesystem (root
101 filesystem). This may be the file system in full, or the writable
102 part of the overlay filesystem.
104 * +work+ is the work directory for the overlay mount, unless the
105 subhost is equipped with an image file for its root filesystem (in
106 which case that image file offers the work directory)
108 * +mnt+ is optional. It is used as the mount target for the image
109 file when the subhost has one.
111 * +$SUB.img+ (for the subhost named +$SUB+)is the optional image file
112 for a subhost. The image file must itself have top directories
113 +/root+ and +/work+ which then are used instead of those of the
114 subhost tree. I.e. with an image file, the overlay root portion is at
115 +$SUB/mnt/root+ and the associated work directory is at
116 +$SUB/mnt/work+ (following the mounting of the image +$SUB.img+ onto
122 Each subhost +$SUB+ gets set up with a network namespace +$SUB+, with
123 +veth+ virtual cabling for the +$BRIDGES+ it is declared to attach to.
125 The cable interfaces show up inside the +$SUB+ namespace as +eth0+,
126 +eth1+, etc., while the host side interfaces have +$SUB+ as prefix,
127 followed be the same number.
133 .start a subhost named +future+
135 # ./control start future
138 Starting a subhost will enter a bash shell "inside" the subhost. The
139 subhost is "running" as long as that shell exists; it is basically
140 like the "init" of the sandboxed subhost.
142 When exiting a subhost, its mounts and network namespace hang around,
143 but all its processes have got killed. This is like a "hibernation
144 state" for the subhost, which may be restarted (without stopping)
145 using the start command again.
147 .stop a subhost named +future+
149 # ./control stop future
152 The stop command unmounts everything for the subhost and deletes the