Affected versions: CentOS Stream 9

📖 ~1 min read

Table of contents
  1. Symptom & Impact
  2. Environment & Reproduction
  3. Root Cause Analysis
  4. Quick Triage
  5. Step-by-Step Diagnosis
  6. Solution – Primary Fix
  7. Solution – Alternative Approaches
  8. Verification & Acceptance Criteria
  9. Rollback Plan
  10. Prevention & Hardening
  11. Related Errors & Cross-Refs
  12. References & Further Reading

Symptom & Impact

`dnf` reports the lock is held by a dead PID and refuses to run.

Environment & Reproduction

Common after a killed dnf or container exit mid-transaction.

Root Cause Analysis

Stale lock files in /var/lib/rpm and /var/cache/dnf remain after crash.

Quick Triage

Check with `lsof /var/lib/rpm/.rpm.lock` and `fuser` on the path.

Step-by-Step Diagnosis

Confirm no live rpm/dnf process, then identify the stale PID in metadata.

Illustrative mockup for centos-stream-9 — terminal_or_shell
Stale RPM lock diagnostics in terminal — Illustrative mockup — Progressive Robot

Solution – Primary Fix

Remove the lock with `rm -f /var/lib/rpm/.rpm.lock` after verifying no holder.

Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

Illustrative mockup for centos-stream-9 — logs_or_journal
journal and log evidence for Stale RPM lock — Illustrative mockup — Progressive Robot

Solution – Alternative Approaches

Restart `packagekit` and retry in maintenance.

Verification & Acceptance Criteria

`dnf makecache` completes without lock errors.

Rollback Plan

Restore lock state from backup if ACLs were changed.

Prevention & Hardening

Configure `nice`/`ionice` and monitor for OOM during package ops.

Linked to OOM events and forced reboots during upgrade.

Related tutorial: View the step-by-step tutorial for centos-stream-9.

View all centos-stream-9 tutorials on the Tutorials Hub →

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

CentOS Stream 9 RPM and dnf locking reference.

Need Expert Help?

If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today — we respond within one business day.