Skip to content

Latest commit

 

History

History
39 lines (20 loc) · 2.47 KB

INTERNALS.md

File metadata and controls

39 lines (20 loc) · 2.47 KB

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.

Provision

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.

Generating image

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.

Network

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.

Compressed RAM(zram)

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 hacks

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.

Debug

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.