||6 months ago|
|HOWTO.adoc||7 months ago|
|README.adoc||7 months ago|
|bootstrap||7 months ago|
|cgroups2-usage||7 months ago|
|cgroups2listener.lsp||7 months ago|
|cgroups2listener.sh||7 months ago|
|cgroups2report||7 months ago|
|cgroupsetup.sh||7 months ago|
|check-mounts.sh||7 months ago|
|control||7 months ago|
|gnt-start||6 months ago|
|go||7 months ago|
|pretend-boot||7 months ago|
|subhost-init||7 months ago|
This is the script collection for a bespoke "subhost" platform for running sandboxed services directly on the infrastructure hosts rather than within virtual machines (VM).
pretend-boot script runs a subhost almost as if booted in a
virtual machine, except of course, that it really is merely an
"unshared sandboxing" executed by the the host kernel.
# ./pretend-boot mysubhost
pretend-boot sets up the
/opt/sub/mysubhost/live directory that it
uses as root filesystem mount point. It requires the variables DISKS
and BRIDGES to be set, either as environment variables, or via a
configuration file that it by default expects to find at
config would be a textfile, or in
bash source file, that should set the variables
BRIDGES for running the subhost.
DISKS variable is an array declaring the disks in terms the
partitions to mount. Each array element has three parts with ":"
the device node name to use in the subhost
the partition index
the disk image file on the host
The very first element of
DISKS is the subhost root filesystem,
which gets loop-mounted during the "pretend boot".
DISKS=( vda:1:/disks/disk1.raw vdb:1:/disks/disk2.raw )
BRIDGES variable is an array declaring the network interfaces in
terms of their host appearance. Each array element has two parts with
":" between them:
the host bridge to link up with
the subhost interface’s MAC address
BRIDGES=( homenet:06:a7:dd:b4:02:f2 )
Obviously the first ":" separates the bridge name from the MAC address, which in itself includes 5 (more) ":" characters.
subhost-init script is copied into the subhost root filesystem,
and it first performs the rudimentary pre-pivot tasks (mounting "proc"
etc.), the runs rcS and rc2 before entering into a plain wait for
anything to be written to
/run/initctl which works as an immediate
poweroff for the subhost.
control script is an alternative subhost run script used for
experimentation and debugging.
It sets up the subhosts fully within the $SUBHOST directory tree,
/opt/subhost, and each subhost system is represented
there as its own directory tree whose top level contains the
configis a bash include file that declares the subhost setup for the control script.
liveis the root of the subhost filesystem when activated. It gets set up either as an
rbindmount of the subhost
rootor as an
overlaymount placing the subhost
rootover a common, read-only base filesystem.
rootis the directory that contains the subhost filesystem (root filesystem). This may be the file system in full, or the writable part of the overlay filesystem.
workis the work directory for the overlay mount, unless the subhost is equipped with an image file for its root filesystem (in which case that image file offers the work directory)
mntis optional. It is used as the mount target for the image file when the subhost has one.
$SUB.img(for the subhost named
$SUB)is the optional image file for a subhost. The image file must itself have top directories
/workwhich then are used instead of those of the subhost tree. I.e. with an image file, the overlay root portion is at
$SUB/mnt/rootand the associated work directory is at
$SUB/mnt/work(following the mounting of the image
$SUB gets set up with a network namespace
veth virtual cabling for the
$BRIDGES it is declared to attach to.
The cable interfaces show up inside the
$SUB namespace as
eth1, etc., while the host side interfaces have
$SUB as prefix,
followed be the same number.
# ./control start future
Starting a subhost will enter a bash shell "inside" the subhost. The subhost is "running" as long as that shell exists; it is basically like the "init" of the sandboxed subhost.
When exiting a subhost, its mounts and network namespace hang around, but all its processes have got killed. This is like a "hibernation state" for the subhost, which may be restarted (without stopping) using the start command again.
# ./control stop future
The stop command unmounts everything for the subhost and deletes the network namespace.