Back up, recover and decommission a target#

How-to · Operators

shirudo refuses to paper over a state it cannot vouch for, so several failures have one way out: a reboot. One has no way out in place. This page lists what to back up, how to get a target out of each state that blocks it, and how to take a target out of service.

Every procedure here works with shirudo as it is. Where no recovery exists, the page says so.

Before you begin#

  • Root on the target. On the target, shirudo stands for the runtime image’s binary, /run/shirudo/runtime/usr/bin/shirudo (Run shirudo on the target).

  • For a decommission, the operator host that builds and signs the target’s UKI.

What to back up#

Item

Why it matters

/var/lib/shirudo/eventlog

The target’s measurement history across boots. Nothing else holds it, so it is evidence you cannot recreate.

/var/lib/shirudo/config-update/

The config activation journal: each activation with its TPM reset and restart counts. Evidence, tied to this target’s TPM.

/var/lib/shirudo/images/

The runtime image and every config bundle the target has activated, named by root hash. The operator holds the originals.

/var/lib/shirudo/upatches/ and /var/lib/shirudo/bpm/

The upatch archive that init restores at boot, the installed packages and the tree state. The registry holds the packages.

/etc/shirudo/

Host files: bpm/environment, map-export.env, and shirudo.conf when the dracut module takes the initrd’s bootstrap file from there.

/etc/systemd/system/shirudo*.d/

The runtime drop-ins of the shirudo units.

On the operator host

The signing keys (Manage signing keys), the image source directories and bootstrap files, the UKI build inputs, and each target’s attestation key name, endorsement key pin and expected values (Attest targets).

Back up a target#

The seal stops writes to /var/lib/shirudo but not reads, so root can copy the state while enforcement is up.

  1. Archive the state and the host configuration:

    target# tar --create --gzip --file=<archive> /var/lib/shirudo \
        /etc/shirudo /etc/systemd/system
    

    <archive> is a path outside /var/lib/shirudo, for example /root/shirudo-state.tar.gz.

  2. Save the journal of shirudo’s messages:

    target# journalctl -t shirudo -o export > <journal-file>
    
  3. Copy both files off the target.

Restore#

shirudo has no restore command, and while enforcement is up the seal refuses root’s writes into /var/lib/shirudo. You cannot restore files into a running target. Rebuild a lost target instead:

  1. Provision it again (Boot integration, Initialize a target).

  2. Install its packages from the registry (Deliver packages).

  3. Keep the old eventlog, journal and activation journal with your records as the history of the old installation.

Do not copy an eventlog, an activation journal or the tree state /var/lib/shirudo/bpm/upatch-tree/ onto another target. The tree state records how far its own target got in the tree, and another target would skip every operation up to that point.

Plan for eventlog growth#

The eventlog grows by one record for each boot, upatch load and unload, key revocation and tree operation. shirudo never rotates or truncates it, has no command to, and the seal stops root from doing it. In the test VM, the init record of a target with two certificates takes about 2 KB and a load adds a few hundred bytes:

target# shirudo status --show-full
...
  Eventlog:              /var/lib/shirudo/eventlog  (2 entries, 2324 bytes)
...

Every command that reads the eventlog reads all of it, plus the pending record of the initrd, and refuses when the two exceed 8 MiB (8388608 bytes). eventlog.max_bytes in the signed config sets a lower cap: at the cap, upatch load and upatch unload, and the package and tree commands built on them, refuse with eventlog_full. init checks the same cap and the same read limit before it binds the register, so a target whose eventlog reaches either one fails init at every boot (init failed after it recorded the boot’s activation). At about 2 KB per boot, that takes a few thousand boots with no other events, and fewer with loads and tree operations.

Watch assets.eventlog_bytes in shirudo status --json or the keepalive (Monitor and export telemetry), and decommission and reprovision a target well before it reaches the limit.

Nothing removes old bundles from /var/lib/shirudo/images either. Each config you activate stays there under its root hash, so size config images with the --size option of shirudo-gen-image.

Recover a target#

Find the state from what the target shows, then follow its section.

What you see

State

Way out

reboot-pending, Pending: yes from image status, and shirudo: image state: Operation now in progress from other commands

A config activation is pending

Reboot.

The same, with init: boot-restore failed or init: incomplete in the journal of this boot

init failed after it recorded the boot’s activation

Fix the cause and reboot.

boot-restore: failed to apply <file> at every boot

An archived upatch no longer loads at boot

Boot the previous kernel, remove the upatch, boot the new one. If no kernel loads it, decommission.

tampered with the config activation record does not belong to this TPM boot, and shirudo: image state: Stale file handle

TPM reset or restarted without a reboot

Reboot if you know the TPM was reset; otherwise handle an incident first.

A config activation is pending#

Symptoms:

  • shirudo status reports reboot-pending with the reason a config activation is pending until the next reboot.

  • shirudo image status prints Pending: yes and exits 1.

  • Every other command prints shirudo: image state: Operation now in progress and exits 1.

Cause: shirudo image update stopped after it saved the pending selection, or init failed after it recorded this boot’s activation (init failed after it recorded the boot’s activation).

  1. Read why in the journal:

    target# journalctl -b -t shirudo
    
  2. Reboot when it suits you. shirudo never reboots a node itself, and the node keeps running in this state with enforcement up.

  3. Check after the reboot that shirudo status reports ok and shirudo image status prints Pending: no and Consistent: yes.

At the next boot, init verifies the pending selection, records a fresh boot activation and completes. There is no command that clears a pending activation in the same boot, and the seal stops you from removing the journal.

init failed after it recorded the boot’s activation#

init records the boot’s config activation before it restores the archived upatches and binds the TPM register. A failure in either step leaves the activation pending. The journal shows one of:

init: boot-restore failed; further changes and attestation remain blocked
init: incomplete: LSM active and upatches loaded, but the TPM register did not advance

In this state the LSM is attached and enforcement is up. The upatches restored before the failure stay loaded, the register is not bound, and shirudo status reports reboot-pending with the ChainIntact detail no register bound this boot (init incomplete). Every command that reads target state is refused, except status and image.

A second init in the same boot does not help. It stops with:

image: activation is pending; further changes are blocked
init: loading authenticated boot settings failed: Operation now in progress
  1. Find the step that failed in the journal of both runs:

    target# journalctl -b -u shirudo-initrd.service -u shirudo.service
    
  2. Fix the cause. A cause in the boot inputs needs new boot inputs (Boot integration). An archived upatch that fails to load needs the next procedure.

  3. Reboot.

An archived upatch no longer loads at boot#

Symptoms:

  • The journal shows boot-restore: failed to apply <file> before the init lines above.

  • shirudo status reports reboot-pending, and commands other than status and image status fail with shirudo: image state: Operation now in progress.

Cause: init restores the archive in name order and stops at the first upatch that fails, without unloading what it already loaded. The usual cause is a new kernel on which the upatch fails with verifier_rejected, attach_target_missing or kernel_abi_unsupported. For an XDP upatch, a line XDP: attach <device> before it names a device whose driver refused the program: a NIC added since the load, or a setting that survived the reboot, in the NIC’s firmware or the hypervisor, such as LRO, header-data split or a device without multi-buffer XDP.

init restores the same archive at every boot, so a reboot fails the same way. These do not work:

  • A second init: it refuses the pending activation.

  • shirudo bpm uninstall and shirudo upatch unload: every command that reads target state is refused, except status and image.

  • Deleting the file from /var/lib/shirudo/upatches: the seal refuses it.

For an XDP device, undo the setting or remove the device, and reboot. A device that cannot take XDP needs a upatch signed with a class mask that leaves it out. Otherwise remove the upatch from a boot on which it loads:

  1. Before you reboot, read the name of the failed upatch:

    target# journalctl -b -u shirudo-initrd.service
    

    The line is boot-restore: failed to apply <file>.

  2. Boot a kernel on which the upatch loads, usually the previous one, from its UKI in the boot menu. Its runtime image must still be where its UKI bootstrap file names it, in /var/lib/shirudo/images.

  3. Check that shirudo status reports ok.

  4. Remove the upatch. Uninstall its package with shirudo bpm uninstall <package>, unload it with its unload directive (shirudo upatch unload), or, for a upatch from the tree, publish a delete operation and let the tree sync apply it.

  5. Boot the new kernel’s UKI and check init as described in Initialize a target.

If no kernel loads the upatch, shirudo offers no recovery in place. Decommission the target and provision it again. To avoid the state, make sure every archived upatch loads on a new kernel before you reboot into it (Upgrade shirudo and the kernel).

TPM reset or restarted without a reboot#

The activation journal records the TPM’s reset count, which only a TPM reset or TPM2_Clear changes. When it changes while the system runs:

  • Every command that reads target state, except status and image, prints shirudo: image state: Stale file handle and exits 1. init, genkey, build, help and version skip that check.

  • shirudo status reports tampered with the reason the selected config cannot be verified against its records, and ConfigActive reads the config activation record does not belong to this TPM boot.

  • The register can be gone, which ChainIntact reports as a warning.

A TPM restart, as a resume from hibernation does, keeps the reset count but clears the config PCR and the register: commands print shirudo: image state: Structure needs cleaning, and ConfigActive reads the config PCR, activation records and mounted config disagree. A resume from suspend to RAM keeps both, and the target runs on; a config activation it finds pending stays pending until the next reboot.

If you know the TPM was reset or restarted, reboot. Do not run init again: after a TPM reset it binds the register from the root file system, which a verifier that pins PCR 11 rejects, and after a restart it records nothing and refuses to bind. If you do not know why the counts changed, handle the target as in Respond to a tampered target before you reboot. Hardening checklist covers turning hibernation off.

Decommission a target#

Enforcement cannot be switched off while the target runs: the LSM links are held by pins in the private bpffs that only shirudo could remove, and shirudo has no command that removes them. Taking a target out of service is a reboot into a boot path without shirudo.

  1. Optional: uninstall every package, so the eventlog records each unload:

    target# shirudo bpm uninstall <package>
    
  2. Save the eventlog and the journal as the target’s last record, as in the backup procedure above.

  3. Stop and disable the timers:

    target# systemctl disable --now shirudo-keepalive.timer \
        shirudo-map-export.timer shirudo-bpm-repo-update.timer \
        shirudo-bpm-tree-sync.timer
    
  4. Disable the root service:

    target# systemctl disable shirudo.service
    
  5. Remove the runtime drop-ins you installed (Install the unit drop-ins) and reload systemd:

    target# systemctl daemon-reload
    
  6. Remove the target package, which removes the binary, the units and the dracut module:

    target# apt remove shirudo-target
    

    On RPM-based systems, run dnf remove shirudo-target.

  7. On the operator host, build and sign a UKI whose initrd does not contain the shirudo dracut module and whose kernel command line carries neither bpf.keyring_unsealed=1 nor dm_verity.keyring_unsealed=1, and make it the target’s default boot entry. Without the module, shirudo-initrd.service does not run. Without the parameters, the kernel seals the .bpf and .dm-verity keyrings empty at boot. Regenerating the initrd on the target alone changes nothing a UKI boots. If the shirudo installer added the parameters, it wrote them through grubby, to /etc/default/grub.d/shirudo.cfg or to /etc/kernel/cmdline; remove them there too.

  8. Reboot the target.

  9. Check that the kernel left the .bpf keyring sealed:

    target# cat /sys/module/bpf/parameters/keyring_unsealed
    

    The file reads N. /run/shirudo does not exist.

  10. Remove the state. The seal stopped root from doing this before the reboot:

    target# rm -rf /var/lib/shirudo /etc/shirudo
    
  11. On the operator host, retire the target: remove its attestation key name, endorsement key pin and expected values from your verifier’s records, so that no evidence from it passes verification again.

The register’s NV index 0x01818E00 stays defined in the TPM. If the TPM goes to another use, remove the index with the owner hierarchy’s authorization, for example with tpm2_nvundefine 0x01818E00 from tpm2-tools.

Next steps#