dnf history rollback verified on openEuler — undo reinstalls removed packages, and the boundary against rollback
Verification scope
Section titled “Verification scope”This page’s evidence is the container track (E2, reversible operations) — openeuler/openeuler:latest (online repos, 2026-11-05): the full transaction chain install → history → remove → undo → re-check. Raw log: evidence/logs/openeuler-dnf-history-rollback.log.
Verified: undo inverts one removal
Section titled “Verified: undo inverts one removal”The minimal closed loop (each step’s output logged):
$ dnf -y install tree # Transaction 1: Install$ dnf history listID | Command line | Action(s) | Altered 1 | -y install tree | Install | 1$ dnf history info last | grep 'Transaction ID'Transaction ID : 1$ dnf -y remove tree # Transaction 2: Erase$ dnf -y history undo last # Invert transaction 2 → tree comes back$ rpm -q treetree-2.1.1-2.oe2403sp4.aarch64 # ✓ reinstalledundo’s semantics are inverting a specified transaction: what was Installed in the target transaction gets Erased, what was Erased gets Installed. Combined with the transaction ID table from dnf history list, you can precisely pick one bad operation to invert without touching other transactions.
undo vs rollback: command surface and choosing
Section titled “undo vs rollback: command surface and choosing”$ dnf history --help | grep -oE 'undo|rollback' # verified in testing: both coexistundo <ID> invert a transactionrollback <ID> return to the state after transaction ID (rolling back all intermediate transactions too)Selection rule: for a single clearly bad operation, use undo (smallest blast radius); when a string of upgrades has broken the environment and you want to return wholesale to a known-good state, use rollback. rollback also undoes all intermediate transactions — including your own deliberate later installs; count with dnf history list beforehand how many it will swallow.
Boundaries and safety reminders
Section titled “Boundaries and safety reminders”- Dependency entanglement: undo/rollback inverts dependency installs per the transaction record (reinstalls/removes), but does not roll back configuration file contents — the package is back, but edited configs in /etc remain edited; after a rollback, configuration drift needs manual review;
- Do not casually undo kernel and system-level upgrade transactions: the kernel is an installonly package with complex inversion semantics (multiple kernels coexisting/boot entries); for such scenarios prefer switching back to the old kernel with
grubby+ removing the new kernel withdnf removeafter observation (see kernel dual-track); - The mirror-pinning prerequisite pitfall (recorded in this experiment): the official source’s 302 redirects intermittently time out on some networks (
dnf makecachefails with theFailed to download metadataform; hit twice in this dev session and resolved by pinning a mirror; the failure-scene logs were overwritten by the successful re-run after the fix, with the error form matching that cited in the troubleshooting page) — history operations all depend on metadata; before rehearsing rollback, pin the baseurl to a reachable mirror (Huawei Cloud) or a local source first, and don’t let network problems masquerade as “rollback failure”.
Unverified
Section titled “Unverified”- Rollback across multiple transactions not verified in testing (the sample stays at a single-transaction minimal loop; multi-transaction chain rollback is listed as a later VM long-run item);
- Undo of upgrade transactions (Update-type) not tested in this environment (involves many old/new package-version pairs, a large risk surface — moved to the upgrade page);
- History reconstruction after rpmdb corruption is out of scope for this page.