Previous: /etc/fstab | Table of Contents | Next: ssh access |
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.
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).
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.
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.
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.
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.
Used in /opt/larch-live/session-save/saveovl. This script can be used to customize the creation of the new overlay archive, e.g. by specifying a new location. The default is 'overlay.ovl' on the boot medium.
Used in /opt/larch-live/session-save/saveovl. This script can be used to further customize the creation of the new overlay archive, e.g. by providing an alternative session save menu. Note that if the session-save script specified an alternative device path for saving the overlay, this script will be sought in the 'larch' directory on that path.
Used in /opt/larch-live/session-save/merge_overlay. This script can be used to further customize aspects of the overlay merging process. Note that if the session-save script specified an alternative device path for saving the overlay, this script will be sought in the 'larch' directory on that path.
In initramfs hook larch3. This script allows adjustment of the overlay handling during the boot process, e.g. getting them from another path. Note that the shell environment here is that of the initramfs and thus very limited.
Previous: /etc/fstab | Table of Contents | Next: ssh access |