Previous: Profiles Table of Contents Next: /etc/fstab

larch – a do-it-yourself live Arch Linux CD



Structure of a larch live CD

The vast majority of the code that runs in a live CD/USB system is exactly the same as in a normal system running from hard disk. The main differences arise through the live CD/USB system being based on a read-only root file-system, so various adjustments are necessary to make the areas that must be writable appear to be so. I say 'appear to be' because in general any changes will be lost when the system shuts down, the actual changes being made only in a RAM-based filesystem (but see "Session saving").

squashfs and aufs

In larch, as in many other live CD/USB systems, the ability to (apparently) write to a read-only file-system is provided by aufs (originally derived from unionfs). The file-system is also compressed, using squashfs, so as to fit more data onto the storage device (normally about 2GB of uncompressed code and data can be squeezed onto a 700MB CDROM using this approach). A custom Arch Linux installation (you can choose which packages are installed) is compressed into a squashfs file-system in the file system.sqf, which is placed in the root directory of the boot device.

For use in a live CD/USB system a few changes must be made to some files in the installation. In larch this is (at first) not done directly, the installed system is left in a 'clean' state. Instead of that, an additional union layer is created, in the archive mods.sqf, containing all the modified files (except those in /etc, which are placed in the top, writable, union layer, which is saved in the overlay.ovl archive. The user is free to include (pretty well) any customizations (s)he wants in these overlay files. These files are also placed in the root directory of the boot device.

These system archives are combined when the live CD/USB system boots. They are mounted as branches of a union file-system with the overlay above the 'standard' system, so that files in the overlay have priority over the original ones. The top layer of the union is a tmpfs writable layer (thus, effectively, making the whole system writable), into which the archive overlay.ovl is unpacked during booting. As the changes are only stored in RAM, they will, however, be lost when the system shuts down (unless using the session saving feature).

initramfs and mkinitcpio

It is, in general, not possible to boot directly into a live CD/USB system. Some form of 'initrd' or 'initramfs' is required, in order to find the boot device, get hold of the file-system and prepare it for running. Many modern GNU/Linux systems use initrd/initramfs (the former being now deprecated) as a matter of course, for loading the necessary kernel modules, and Arch Linux is no exception, a modular initramfs system (mkinitcpio) being the standard way to boot Arch Linux, and larch also takes advantage of it, although some additions need to be made to boot live CD/USB systems.

/etc/inittab, /etc/rc.sysinit and /etc/rc.shutdown

The initial boot script and the shutdown script must be customized for use in a larch live environment. There are numerous ways of achieving that and larch has tried out several. In version 5.3.2 a method was introduced which involves replacing the original /etc/rc.sysinit and /etc/rc.shutdown scripts by modified versions which are fully equivalent to the official scripts but split off certain parts into functions which can be overridden when used in a larch live system. The 'larch-live' package provides the files /etc/larch-sysinit and /etc/larch-shutdown which provide the new versions of these functions for live use.

The need to overwrite certain system files is a bit messy, and means that the initscripts package should not be updated in the live system, but I hope the official package will sometime itself contain suitable versions of the '/etc/rc.sysinit' and '/etc/rc.shutdown' files which separate out the relevant functions so that larch doesn't need to overwrite them.

Although it is not strictly necessary (because the substituted files are fully equivalent to the official ones), larch saves the originals as '/etc/rc.sysinit.larchsave' and '/etc/rc.shutdown.larchsave', so that these can be restored on installation by larchin (this might avoid later confusion).

It is possible to use a customized version of '/etc/inittab', by putting the new version in the profile (in 'rootoverlay') - for example one could customize the handling of the first terminal, e.g. to allow automatic login. The original inittab is saved as '/etc/inittab.larchsave', so that it can be restored if the system is installed using larchin.

One addition in the larch version of the initscripts is the automatic generation of a new '/etc/fstab' (using the script gen_fstab, which bases the result on the devices which are detected in the system). Otherwise it behaves much the same as the version in a normal Arch Linux system. However, the remount of the root-filessystem and file-system checks have been left out as they are not relevant in a live-CD environment. No partitions are mounted and, by default, swap is not enabled. The reason is primarily that for use as an installation CD, it is better not to have any partitions mounted, because it is quite likely that the partitions will be edited in preparation for the installation. Passing boot parameter 'swap' will enable swap if there is a suitable partition (or it can be done manually using 'swapon -a').

'/etc/rc.shutdown' is adapted by adding code to deal with session-saving (writing changes back to the boot medium) and to eject the live-CD. Unlike in the normal version, the hardware clock is not reset.

Previous: Profiles Table of Contents Next: /etc/fstab