Previous: /etc/fstab Table of Contents Next: ssh access

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



Saving a session back to the boot device (or even somewhere else)

An easy way to create a customized live-USB-stick is to start from an existing one, make whatever changes you like, and then save the result back to the USB-stick.

Overlay archives, overlay.ovl and mods.sqf

In larch the overlay file-system (in the compressed file 'overlay.ovl') can be rebuilt from the state of the live system when it shuts down. This is handled primarily by the script /opt/larch-live/session-save/saveovl, which is called from the customized shutdown function. If the medium is writable and contains a file 'larch/save', the user is offered the possibility of rewriting the overlay archive, thus saving the current state.

The main overlay archive (overlay.ovl) is unpacked into memory at boot and repacked when saving the session at shutdown. When this archive grows too large it will reduce the amount of available memory, perhaps to an unacceptable extent. It will also lengthen boot and shutdown times. To counter this, it is possible to merge the overlay archive into the middle union layer in mods.sqf (which is normally not copied to memory), thus restoring the rapid load and save times for overlay.ovl, and maximizing the available memory. I call this process 'overlay merging', and it is offered as a shutdown option. It takes longer to execute than a normal session save, but from larch version 5.2 a new aufs option allows the merging to be done quicker than it was previously and without significant extra memory requirements. In this version a separate aufs union of the two overlay layers is mounted in which the whiteouts are visible. This union can then be squashed directly, without requiring the new, merged overlay to be rebuilt in memory. As it is a feature of aufs, overlay merging is no longer supported for unionfs (note that unionfs is at present not actively supported in larch anyway).

Special places in /var

It was considered undesirable to include some things in the '/var' directory in the session saves, primarily because of the space they occupy. Firstly, the standard pacman package cache, '/var/cache/pacman/pkg' - if you do want to save your cache, you should either handle this manually or set up another location using 'CacheDir' in /etc/pacman.conf'. Also the log files (in '/var/log') and '/var/tmp' (temporary files, like '/tmp') are not saved.

Updating packages

It should be possible to include package addition and removal in the list of customizations undertaken using this method, but there are some limitations. Apart from size considerations (the top level overlay is unpacked into memory at boot), there is also a limitation connected with the kernel. Essentially, the kernel and its modules may not be updated. If you do this, you may well make a mess of your system. In other words, be very careful with 'pacman -Su' - only upgrade selected packages.

The reason for this is that the kernel is not contained within the squashed file-system, but is held separately on the boot medium, while its modules are contained in the squashed system and also in the initramfs. Updating these is not impossible (if booting from a writable medium), but pacman cannot do it and it is not straightforward (e.g. using a CD to boot to a USB-stick on a computer not supporting USB boot would additionally need a new CD). A complete rebuild of the live system might be a better approach. And using 'larchify' it should even be possible to perform such a rebuild from within the running live system.

Activating and deactivating the session-saving feature

As mentioned above, for this feature to be available, there must be a file with the name 'save' in the boot medium's 'larch' directory.

Customizing the behaviour using scripts

Some aspects of the session saving can be customized by writing scripts to override the default behaviour. These scripts are (in general) kept on the boot medium, in the 'larch' directory. As these are shell scripts and their use requires some knowledge of the inner workings of the larch live system, it will almost certainly be necessary to read the existing larch scripts where the custom scripts are 'sourced' if you want to write your own scripts to change the behaviour of the larch live system.

Previous: /etc/fstab Table of Contents Next: ssh access