Rolling Back a Broken System Update with rpm‑ostree Snapshot Recovery

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

ItemCommandNotes
rpm‑ostree installedsudo dnf install rpm-ostreeMost Fedora Silverblue, RHEL CoreOS, and openSUSE MicroOS ship with it.
A recent snapshotrpm-ostree statusShows the current commit and any pending updates.
A bootloader that supports multiple boot entriessudo grub2-editenv listGRUB is the default on most RPM‑based distros.
Root accesssudo -iRollback requires root.

1. Identify the problem

The first step is to confirm that the system is indeed broken. Common signs:

  • systemctl status shows services failing to start.
  • journalctl -xe contains errors about missing libraries or configuration files.
  • rpm-ostree status shows a pending or failed state.
$ 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:

  1. Marks the current deployment as rollbacked.
  2. Sets the previous deployment as the new boot target.
  3. 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:

  1. 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.target
    
  2. Enable the service:

    $ sudo systemctl enable rpm-ostree-rollback.service
    
  3. Configure 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-ostree
    
  • Audit rollback commands – log every rpm-ostree rollback invocation:

    $ 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

SymptomLikely causeFix
rpm-ostree rollback fails with “no previous deployment”First deployment, no historyReboot to the same commit, then run rpm-ostree rollback after a failed update
Services still fail after rollbackPackage corrupted in both snapshotsRebuild the image or replace the package manually
Bootloader shows “invalid signature”Keyring out of daterpm-ostree key-import /etc/pki/rpm-gpg/RPM-GPG-KEY-<dist>
Disk space exhausted by old snapshotsNot cleaning uprpm-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:

  1. rpm-ostree status showed a pending deployment.
  2. rpm-ostree rollback was executed.
  3. The node rebooted to the previous kernel.
  4. systemctl status sshd returned active.
  5. The old kernel was kept for audit purposes (--keep flag).
  6. 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/fstab or /etc/udev/rules.d that were added manually.

In these cases, a manual recovery or a full reinstall may be necessary.


11. Best practices for a rollback‑ready environment

  1. Keep the keyring updated – run rpm-ostree key-import whenever the distributor rotates keys.
  2. Test updates in a staging environment – use rpm-ostree upgrade --dry-run to preview changes.
  3. Automate rollback monitoring – use a watchdog or a systemd timer that triggers rpm-ostree rollback if a critical service fails after an update.
  4. Document rollback procedures – include the exact commands and commit hashes in your runbooks.
  5. 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