Building the live system

Once we have an Arch Linux installation and have specified our customizations in the profile, we can put together the basic ingredients of a live medium. Firstly there is the '/boot' directory, containing the kernel, the initramfs (a small compressed file-system into which the kernel boots initially) and files belonging to the bootloader. The bulk of the system will be in a single squashfs archive, 'system.sqf', residing on the medium in the /larch directory. This archive contains the essentially untouched Arch installation. A further - much smaller - squashfs archive ('mods.sqf') is built containing the configuration defined in the selected larch profile. This latter will 'overlay' the underlying system as a branch of the aufs root file-system used when running live. Various other data and configuration files special to the larch live system are also kept in the /larch directory.

The standard way of supporting data persistence in this version of larch is to use the boot medium as a writeable overlay branch in the root ('/') aufs file-system. This can of course only work if the boot medium is writeable and is formatted with a linux file-system (standard is 'ext4'). In this case the 'mods.sqf' file will not exist, its contents being unpacked onto the medium. When running without data persistence a temporary writeable layer, in tmpfs (a memory based file-system), is used as the top layer.

Let's call this step, preparing these components so that they can be installed on a suitable medium, 'larchification' (from the verb 'larchify'). At the end of the 'larchification' process, the basic ingredients of the live medium have been created, but the bootloader files are not yet finalized (and nothing has been written to any medium).

For details of the structure of the live system which is built by this stage see this page. A description of the main possibilities for customizing the build process are covered in the profiles documentation.

mkinitcpio and the initramfs

In order to build a suitable initramfs for a larch system, a customized version of 'mkinitcpio.conf' is required. How larch handles this is quite complicated because it aims to retain the normal files so that the live system can later be installed as a normal Arch Linux system, whilst at the same time offering the capability of updating (with 'pacman -Syu') the live system, including the kernel (thus requiring regeneration of the initramfs for the system). The consequence of this ambition is that modifications are made to the 'preset' file within '/etc/mkinitcpio.d' (which are reversible when the live system is installed as a normal Arch Linux system) and a special mkinitcpio' configuration file, '/etc/mkinitcpio.conf.larch' must be provided (there is a default version supplied in the larch-live package which should be adequate in most cases). If you need to know more see the method 'Builder.gen_initramfs' in 'cli/larchify.py'.

Rebuilding using an existing 'system.sqf'

In order to aid experimentation with profile tweaks which do not affect the underlying installation, it is possible to repeat the 'larchify' step without rebuilding the 'system.sqf' archive, which saves quite a bit of time (this is achieved by passing the '-o' option to 'larch-larchify' when running from the command line).

Making a live system from an existing Arch installation

By setting the installation path (with the '-i' option if using the command line) to an existing Arch installation, a live medium can be made from it. One convenient way of doing this is to run the build process from a live system. A larch live system is of course particularly well suited, but most others should work too.

To use an existing system as source, this system must already be mounted, including any sub-mounts (e.g. /home on another partition). The main mount must be with options 'exec,dev', because most of the building is done via a chroot to the installation. This approach to live system generation is probably not a good idea if the installation contains a lot of data - consider how big the result will be ...

Note that some things in '/var' will not be included in the 'live' system. Firstly, the standard pacman package cache ('/var/cache/pacman/pkg') will be excluded. Also the log files (in '/var/log') and '/var/tmp' (temporary files, like '/tmp') are not saved. As some files in '/var/log' are required for certain aspects of logging to function, these are recreated in the initramfs.

Kernel and Initramfs

The larchify script assumes the kernel is the standard one from Arch Linux. It is quite possible to use a custom kernel with larch, so long as it supports squashfs and aufs, but you must tell the script the name of the kernel binary file and the name of the mkinitcpio 'preset', by placing these with a space-separator in a file called 'kernel' in the profile directory. The defaults are supplied in the larch package's 'data' directory, in the file 'kernel'. Check that you understand how the mkinitcpio system handles kernel updates before you try larch with a custom kernel.