bootmap — keep EFI images and system snapshots in sync
Bootmap is an integrated efi image generator/signer/installer and system backup manager. The bootmap command can be used to query its current state, and to perform various commands. Most of the commands are intended to be run by Pacman hooks during updates, and the only command required for everyday usage is the status command.
Print current images and subvolumes. This is also the default action if no command is specified.
The IMAGE
column gives the list of images. For each $image
, there is an associated Unified Kernel Image $image.efi
in ImageDir
. The filename $image.efi
is also recognised by systemd-boot as a valid boot entry id. The currently booted image is indicated with a tag, and if different, so also is the image that is set for next boot.
The SUBVOLUME
column gives the subvolume that each image is set to boot into. Typically these will consist of the system itself plus a number of backups. The subvolume that currently corresponds to the system root /
is indicated with a tag. These paths are relative to the filesystem root, not the system root.
The USED AS
column indicates where each subvolume lies in the backup sequence, if at all. Upon backing up, Current
becomes Backup 1
, Backup 1
becomes Backup 2
, etc.
If you have any misconfigurations, bootmap will also issue a complaint about “extraneous files” - see cleanup for what this means.
(Note) The state displayed by this command is simply the contents of the special subvolume BootmapVol
. Each IMAGE
is a symlink in this folder, and each SUBVOLUME
is a subvolume.
(Note) If you have several linuxes coexisting on the same filesystem in different subvolumes, they can happily use the same BootmapVol
. In this case, each one’s images and backups will show up when the status command is run, but they will otherwise refrain from interacting.
Create images for all installed kernels. This is useful on first install.
Only missing images are created. This means the command has no effect if run a second time. If you really do need to recreate an image, first delete it manually from ImageDir
and BootmapVol
.
Remove extraneous files.
Extraneous files are files in BootmapVol
that should not be there. They can never be produced through normal usage, but may result from incorrect manual editing. When the status command is run it prints a warning showing all such files. You can either check and delete them yourself, or use this convenience command to delete them all.
(Caution) Files may be listed as extraneous as a result of some other misconfiguration, not because they really should be deleted. So use this command with care.
Pacman hooks. Not intended to be invoked manually, only by pacman.
The pre hook removes the image associated to a kernel before it is updated or removed, potentially backing it up along with the system. The post hook creates the image after a kernel is installed or updated. Both hooks also run if there are changes to the microcode files or mkinitcpio that require all kernels to be regenerated.
Bootmap chooses to make backups so as to preserve the “main invariant”: to always keep the N most recent confirmed-working backups (where N = MaxBackups
). This means backups are not always made. In particular, if you run several kernel updates without rebooting, there is no need to worry about all backups being overwritten - at most one backup will be made.
If you are running in a backup, and update or remove the kernel, you will be forcing bootmap to violate its main invariant (because modifying a backup means that it is no longer confirmed-working). In this situation, bootmap will complain but play along anyway. You can check if you are in a backup with the status command.
Backups are created with only one kernel booting into them, even if the original system had multiple kernels. This is because only one kernel is needed to make the backup useable. The kernel used for a backup is chosen to be the same as the one that is currently running.
(Caution) If for some reason you accidentally invoke these commands, you can press Ctrl+D
to exit without performing an action. Do not exit with Ctrl+C
, as this may bypass cleanup and leave behind temporary files and mounts.
Bootmap can be configured through /etc/bootmap.conf
. It also requires a valid /etc/kernel/cmdline
. Its behaviour can be extended through scripts in /etc/bootmap.d
.
Main configuration file. Optional, installed by default.
The file format is INI-style, but without section headers. The allowed options and their default values are as follows:
Path to the bootmap subvolume relative to filesystem root.
This is the subvolume where bootmap keeps its state, consisting of a symlink for each image, and a collection of backup subvolumes. It also used during during the boot process to figure out which subvolume to boot into.
How to name the images that are generated. The possible values, along with what they do, are explained below:
VALUE | EXAMPLE | EXPLANATION |
version | linux-5.15.11 | Kernel version number |
date | linux-2021-12-31-22-19 | Timestamp |
random | linux-80917254 | 8 random digits |
A suffix -n where n >= 2 is also appended afterwards if necessary to make the name unique.
If set, make this kernel the default boot entry after an update.
This mechanism is necessary because bootmap’s design is such that the name of the EFI image to boot changes on each kernel update. So the bootloader has to be told where to find it.
Kernel commandline file. Required, installed by default.
Bootmap reads this file to determine the kernel commandline to use when creating images. It replaces the substring $ROOTDEV
with the current root device, and the substring $SUBVOL
with the correct subvolume on that device the image should boot into.
If you use your own version of this file, make sure to include subvol=$SUBVOL
in the root mount options.
Scripts directory. Optional, not installed by default.
Bootmap outsources some operations to scripts in /usr/lib/bootmap
. You can copy any of these scripts to /etc/bootmap.d
and edit them to modify the default behaviour.
By default, bootmap assumes a working installation of systemd-boot for getting/setting the next boot. Fortunately this functionality can be easily overridden through scripting, allowing the use of other bootloaders, or direct booting by firmware.