Previous: Profiles | Table of Contents | Next: /etc/fstab |
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").
In larch, as in many (most?) other live CD/USB systems, the ability to (apparently) write to a read-only file-system is provided by unionfs (or aufs). 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).
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.
These are the other main files which must be customized for use in a larch live environment. From larch version 5.2, a custom inittab is used which calls special versions of the initialization and shutdown scripts, '/etc/rc.sysinit-larch' and '/etc/rc.shutdown-larch' (these are supplied in the 'larch-live' package). The original inittab is saved as '/etc/inittab.larchsave', so that it can be restored if the system is installed using larchin.
It is possible to use further customized versions of inittab, by putting the new version in the profile used to build the larch system. The example profiles add the automatic login of root on the first terminal, though of course this may be undesirable in many cases.
One addition in '/etc/rc.sysinit-larch' 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'). I removed the 'depmod' call because that is done during CD preparation, so it serves no purpose here. Quite a bit of the standard rc.sysinit will not be relevant in a live CD situation. I have cut some bits out, but I dare say the whole thing could be tidied up by someone who knows what he is doing!
'/etc/rc.shutdown' is adapted (in the form of '/etc/rc.shutdown-larch') 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 |