|
| 1 | +# Upgrade/rollback failure detection in bootc |
| 2 | + |
| 3 | +This document describes how to detect when a reboot failed to enable the staged image in bootc. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +bootc uses different mechanisms to detect boot failures depending on the backend (OSTree vs. composefs+UKI) and the specific point of failure. Understanding these mechanisms is crucial for system administrators and automated tooling that needs to detect failed updates. |
| 8 | + |
| 9 | +## OSTree Backend Boot Failure Detection |
| 10 | + |
| 11 | +For systems using the traditional OSTree backend, bootc relies on OSTree's built-in boot failure detection mechanisms. |
| 12 | + |
| 13 | +### Key Services |
| 14 | + |
| 15 | +1. **`ostree-finalize-staged.service`** - Runs during shutdown to finalize staged deployments |
| 16 | +2. **`ostree-boot-complete.service`** - Runs early in boot to detect finalization failures |
| 17 | + |
| 18 | +When `ostree-finalize-staged.service` fails during shutdown/reboot, this will create |
| 19 | +a stamp file in `/boot`, and then on a subsequent reboot the `ostree-boot-complete.service` |
| 20 | +service will detect it, and then itself exit with a failure mode. |
| 21 | + |
| 22 | +You can monitor the success of both services, though for `ostree-finalize-staged.service` |
| 23 | +note that the failure occurred during the previous boot's shutdown. |
| 24 | + |
| 25 | + |
| 26 | +## Composefs Backend Boot Failure Detection |
| 27 | + |
| 28 | +### Key Services |
| 29 | + |
| 30 | +There is a `bootc-finalize-staged.service` which is similar to `ostree-finalize-staged.service`, |
| 31 | +but there is not currently a similar `-boot-complete.service`. There is also a `bootc-root-setup.service` |
| 32 | +that runs during initramfs to mount the composefs image and set up `/etc` and `/var` - but if this |
| 33 | +service fails, the system will not boot at all (emergency mode or hang). |
| 34 | + |
| 35 | +At the current time then, it is recommended to check the journal for failures from the previous boot: |
| 36 | + |
| 37 | +```bash |
| 38 | +# Check for finalization failures from previous boot |
| 39 | +journalctl -u bootc-finalize-staged.service -b -1 |
| 40 | +``` |
| 41 | + |
| 42 | +### Systemd Boot Assessment Integration |
| 43 | + |
| 44 | +As of a recent OSTree with [this commit](https://github.com/ostreedev/ostree/commit/08487091256b93493f8d692e37ab3d892c758da1) |
| 45 | +it is possible to configure the boot loader entry counting. |
| 46 | + |
| 47 | +At the current time, the composefs backend does not configure boot entry counting, this is likely to be added in the future. |
| 48 | + |
| 49 | +## See Also |
| 50 | + |
| 51 | +- [systemd Automatic Boot Assessment](https://systemd.io/AUTOMATIC_BOOT_ASSESSMENT/) |
| 52 | +- [OSTree Manual](https://ostreedev.github.io/ostree/) |
| 53 | +- [bootc-rollback(8)](man/bootc-rollback.8.md) |
| 54 | +- [bootc-status(8)](man/bootc-status.8.md) |
0 commit comments