Previous versions used chroot. To simplify things for end user, I swithed to Vagrant. You just configure normal virtual machine and run script to generate images. Also, this approach is closer to how system runs on real hardware.
Server machine is used to provision both itself and template machine, because we don't want additional packages(ansible) inside image. But we have to install python2-minimal to make ansible work.
Some directories are excluded from rootfs image to make it more compact: /boot
, /usr/share/doc
, /var/lib/apt/lists
and others, see build.sh
.
Vagrant need static addresses in /etc/network/interfaces
, so before generating image, it is replaced with symlink to /tmp/interfaces
. After generating image it is moved back.
Auto-generated files in /etc/network/interfaces.d
are appended to main interfaces file and removed.
File /tmp/interfaces
is generated by special script, used as systemd service. It enables DHCP for all network interfaces found on the machine.
Some diskless devices do not have enough memory to run all the applications you need. And they can't use swap. Linux kernel feature of RAM compressing(zram) may be helpful. It may be used by creating compressed RAM block devices and using them as SWAP partitions. For best performance number of devices should coinside with number of processor cores.
Boot parameter zram_size_pct
controls what amount of available memory(in percent) will be used for zram. Default is 50. 0 disables this feature.
Scripts are copied from ubuntu zram-config package, the only change is configurable parameter for amount of memory used for zram and compression algorithm.
initrd has custom boot script ram
and hook to incude necessary binaries and modules. Script name is passed to kernel in boot parameters.
Overlays(optional) are mounted using Overlayfs. /AUFS
helper directory is used to make it work.
Apparmor is removed, because it's profiles are not compatible with root FS mounted with Overlayfs.
To look inside what you have built, helper scripts extract-initrd.sh
and extract-rootfs.sh
may be usen to extract generate initrd and rootfs to unpacked-initrd
and unpacked-rootfs
directories.
To get inside initrd shell, you may use boot parameter initrddebug=y
.