Symptoms & scope
- pacman reports unable to lock database.
- A crashed update leaves db.lck while no package frontend is active.
Relevant environment
Arch Linux pacman/libalpm; unlike dpkg’s region-lock files, pacman db.lck is a transaction lock marker.
Recognizable messages (synthetic examples)
error: failed to init transaction (unable to lock database)Check for a live writer before considering a stale marker; the log does not distinguish these cases.
Possible causes
These are possible explanations, not a confirmed diagnosis. Several independent faults can coexist.
- Another pacman or graphical libalpm frontend may be updating the database.
- An interrupted writer may have left a stale lock marker and possibly incomplete packages.
Diagnose safely
Run one command at a time in the relevant session. Read the explanation first. Uppercase placeholders need your own values; tools and privileges vary by distribution. These commands are displayed here and never executed by the website.
Check 1
Reads processes using the lock file; do not use -k. Complete inspection can require administrator read privileges.
fuser /var/lib/pacman/db.lckInterpret the result: A reported process must be examined. No output alone is insufficient: inspect all package frontends and permission limits.
Check 2
Reads recent transaction events without opening or modifying the package database.
tail -n 80 /var/log/pacman.logInterpret the result: A started transaction without completion supports interruption, but a concurrently running transaction can look the same; confirm the process state.
Evidence-guided next steps
Wait for the active libalpm writer
If a legitimate package frontend is active, use that frontend’s progress view and wait for completion. Close duplicate update tools and run one package operation after the writer exits and releases its lock.
Precautions: Do not remove db.lck or kill the writer while it is applying files and hooks.
Recovery / rollback: Waiting has no package rollback. Reopen the duplicate frontend only after the active transaction has finished.
Did this solution help you?
Remove only a proven stale pacman lock
Only after confirming no pacman or other libalpm writer is active, remove the stale /var/lib/pacman/db.lck with administrative privileges. Then check local database consistency with pacman -Dk and review the interrupted transaction before completing a full supported system upgrade.
Precautions: This advice applies to pacman’s marker, not dpkg lock files. A stale lock does not establish that the interrupted package set is healthy.
Recovery / rollback: The next transaction recreates its lock automatically. For detected package/database damage, restore a coherent snapshot or use Arch’s recovery procedure rather than restoring an orphan lock.
Did this solution help you?
References & review
This guide was prepared from primary project or distribution sources and reviewed on the date shown. This is an editorial source check, not evidence that a fix was reproduced on your hardware. Diagnostic log examples are synthetic fixtures. Version-dependent details must be checked against your installed release.
- Arch pacman manual: query, sync and alternate system roots (project or distribution documentation)
- ArchWiki: pacman lock and file-conflict recovery (project or distribution documentation)