When a system update goes wrong, you don’t have to reboot the whole machine
A broken update can leave a system in a state where it still boots, but services are mis‑configured, libraries are missing, or the kernel is corrupted. On a traditional RPM‑based distribution, you might end up running yum reinstall or even a full reinstall from a rescue disk. With rpm‑ostree, the recovery path is cleaner: the system is a read‑only tree that can be rolled back to a previous snapshot in a single command. This post walks through that process, explains the trade‑offs, and shows how to keep the rollback path secure and reliable.
Why rpm‑ostree matters for security
- Atomic updates – the entire system is updated as a single transaction. If the transaction fails, the system remains in the previous state.
- Immutable root – the root filesystem is read‑only. A compromised process cannot modify system binaries without a deliberate upgrade.
- Rollback support – a snapshot of every transaction is kept. You can revert to a known‑good state without touching the disk layout or bootloader.
- Auditability – each commit is signed by the distributor’s key. You can verify that the rollback image is authentic.
These properties are especially valuable for hardened servers and critical infrastructure where a single mis‑configured package can expose the machine to privilege escalation or denial of service.
Prerequisites
| Item | Command | Notes |
|---|---|---|
| rpm‑ostree installed | sudo dnf install rpm-ostree | Most Fedora Silverblue, RHEL CoreOS, and openSUSE MicroOS ship with it. |
| A recent snapshot | rpm-ostree status | Shows the current commit and any pending updates. |
| A bootloader that supports multiple boot entries | sudo grub2-editenv list | GRUB is the default on most RPM‑based distros. |
| Root access | sudo -i | Rollback requires root. |
1. Identify the problem
The first step is to confirm that the system is indeed broken. Common signs:
systemctl statusshows services failing to start.journalctl -xecontains errors about missing libraries or configuration files.rpm-ostree statusshows apendingorfailedstate.
$ rpm-ostree status
Deployments:
0: 2026-12-05-12:34:56-abcdef1234567890 (booted)
1: 2026-12-04-08:21:13-123456abcdef7890 (pending)
If the current deployment is booted but services are failing, the update may have partially applied. If the deployment is pending, the system is still in the middle of applying the new commit.
2. Verify the integrity of the current and previous commits
Before rolling back, make sure the previous commit is still valid and signed. rpm‑ostree keeps a signed manifest for each commit.
$ rpm-ostree verify
If verification fails, you may need to fetch the key from the distributor or rebuild the image. A failed verification is a red flag that the rollback itself could be compromised.
3. Rollback to the previous snapshot
The simplest rollback command is:
$ sudo rpm-ostree rollback
This command:
- Marks the current deployment as
rollbacked. - Sets the previous deployment as the new boot target.
- Reboots the system automatically.
If you want to keep the current deployment for debugging, use --keep:
$ sudo rpm-ostree rollback --keep
The --keep flag preserves the current commit in the deployment list, allowing you to boot it manually later.
What happens under the hood?
rpm‑ostree swaps the bootloader entries:
$ sudo grub2-editenv list
You’ll see two entries: bootloader_entry pointing to the new commit and bootloader_entry_prev pointing to the old one. The rollback command updates the bootloader_entry to the previous commit and clears the pending flag.
4. Verify the rollback
After reboot, confirm that the system is running the expected commit:
$ rpm-ostree status
Deployments:
0: 2026-12-04-08:21:13-123456abcdef7890 (booted)
1: 2026-12-05-12:34:56-abcdef1234567890 (rollbacked)
Check that services are running:
$ systemctl is-active sshd
active
If the rollback still leaves services broken, the issue might be deeper (e.g., a corrupted package that exists in both snapshots). In that case, you’ll need to rebuild the image or manually replace the offending package.
5. Clean up old snapshots
rpm‑ostree keeps a history of deployments. Over time, this can consume disk space and clutter the bootloader. Use rpm-ostree cleanup to prune old deployments:
$ sudo rpm-ostree cleanup -m 2
The -m flag keeps the most recent two deployments. Adjust the number based on your retention policy.
Caveat – If you plan to use the older deployment for forensic analysis, do not prune it. Keep a copy in a separate archive.
6. Automating rollback for critical services
For services that must never be broken (e.g., SSH, database), you can enforce a rollback policy:
Create a systemd service that watches for failed deployments:
[Unit] Description=Rollback on failed deployment After=network.target [Service] ExecStart=/usr/bin/rpm-ostree rollback Restart=no [Install] WantedBy=multi-user.targetEnable the service:
$ sudo systemctl enable rpm-ostree-rollback.serviceConfigure a watchdog – if the service fails to start, the watchdog will reboot the machine, ensuring the rollback occurs.
This approach guarantees that a failed update does not leave the system in an insecure state for longer than a few minutes.
7. Security‑specific considerations
7.1. Protecting the rollback image
Because the rollback image is stored on the same immutable root, it inherits the same integrity guarantees. However, you should:
- Verify signatures before applying the rollback (
rpm-ostree verify). - Keep the keyring up to date – if the distributor rotates keys, update the keyring with
rpm-ostree key-import.
7.2. Preventing rollback abuse
An attacker who gains root could trigger a rollback to a known‑good state that contains a backdoor. To mitigate:
Use signed bootloader entries – GRUB can verify the signature of the kernel and initramfs.
Restrict root access – enforce SELinux policies that limit who can run
rpm-ostree rollback. For example:$ semanage fcontext -a -t rpm_exec_t "/usr/bin/rpm-ostree" $ restorecon -v /usr/bin/rpm-ostreeAudit rollback commands – log every
rpm-ostree rollbackinvocation:$ sudo auditctl -w /usr/bin/rpm-ostree -p x -k rpm-rollback
7.3. Avoiding rollback to a compromised snapshot
If an attacker has already compromised a snapshot, rolling back to it will re‑introduce the compromise. To guard against this:
- Maintain a separate “trusted” deployment – a minimal image that you rebuild manually and sign.
- Use
rpm-ostree rollback --to <commit>– specify a known‑good commit hash rather than the previous one.
$ sudo rpm-ostree rollback --to 123456abcdef7890
8. Troubleshooting common issues
| Symptom | Likely cause | Fix |
|---|---|---|
rpm-ostree rollback fails with “no previous deployment” | First deployment, no history | Reboot to the same commit, then run rpm-ostree rollback after a failed update |
| Services still fail after rollback | Package corrupted in both snapshots | Rebuild the image or replace the package manually |
| Bootloader shows “invalid signature” | Keyring out of date | rpm-ostree key-import /etc/pki/rpm-gpg/RPM-GPG-KEY-<dist> |
| Disk space exhausted by old snapshots | Not cleaning up | rpm-ostree cleanup -m 2 or use --prune |
9. Real‑world example: a broken kernel update
On a production RHEL CoreOS node, a kernel update introduced a regression that broke the sshd service. The node still booted, but SSH refused connections. The steps taken were:
rpm-ostree statusshowed a pending deployment.rpm-ostree rollbackwas executed.- The node rebooted to the previous kernel.
systemctl status sshdreturnedactive.- The old kernel was kept for audit purposes (
--keepflag). - A cleanup retained only the last two deployments.
This quick rollback avoided a 30‑minute outage and preserved the audit trail for compliance.
10. When to avoid rpm‑ostree rollback
- Non‑atomic updates – if the update involved manual configuration changes outside the rpm‑ostree tree (e.g., editing
/etc/ssh/sshd_config), rollback will not revert those changes. - Custom packages – if you installed packages from third‑party repositories, they are not part of the rpm‑ostree snapshot. You’ll need to reinstall them manually.
- Hardware changes – a rollback does not revert changes to
/etc/fstabor/etc/udev/rules.dthat were added manually.
In these cases, a manual recovery or a full reinstall may be necessary.
11. Best practices for a rollback‑ready environment
- Keep the keyring updated – run
rpm-ostree key-importwhenever the distributor rotates keys. - Test updates in a staging environment – use
rpm-ostree upgrade --dry-runto preview changes. - Automate rollback monitoring – use a watchdog or a systemd timer that triggers
rpm-ostree rollbackif a critical service fails after an update. - Document rollback procedures – include the exact commands and commit hashes in your runbooks.
- Archive old deployments – for forensic analysis, copy the deployment directory (
/var/lib/rpm-ostree/deploy/<commit>) to a separate storage.
12. Final thoughts
rpm‑ostree’s snapshot recovery turns a potentially catastrophic update into a quick, auditable rollback. By integrating the rollback command into your monitoring stack and enforcing strict key management, you can keep your systems both secure and resilient. The immutable root and signed deployments give you confidence that a rollback will not introduce new vulnerabilities, and the cleanup tools keep your disk usage in check.
When you’re ready to test, spin up a VM, apply a deliberate breaking update, and run rpm-ostree rollback. The experience will reinforce the workflow and help you spot any gaps in your own environment.
See also
- Application-Level Firewalls
- Journalctl hunt for silent root‑kit after brute‑force logins
- Fix the “no route to host” error when nftables blocks traffic from a bridge.
- Fixing a Broken HTTPS on a 1‑GB VPS: Certbot, Nginx, and File Permissions
- Using systemd‑journald Filters to Stop Spurious SSH Login Alerts
- Diagnosing a DNS cache miss after a systemd‑resolved restart