Unable to lock database, Failed to synchronize databases but there is no db.lck in /var/lib/pacman

I got “unable to lock database” message when updating my Manjaro PC with BTRFS.
I search about how to solve it in the internet. I found this archived post by Heart-Of-A-Lion. But there is no db.lck in my /var/lib/pacman/.
Then LinusW just deleted /var/tmp/pamac folder.
I can find my db.lck in /var/tmp/pamac/dbs/. sudo rm /var/tmp/pamac/dbs/db.lck .

If you can’t find db.lck in /var/pamac/dbs/ , check another folder in /var/pamac/

Sorry, I can’t include the links. I don’t know why

You may have a corrupted database. Try sudo rm /var/tmp/pamac/dbs/sync/*.* then refresh the databases. You may also have a corrupted database here /var/lib/pacman/sync, if the first rm doesnt fix it try
sudo rm /var/lib/pacman/sync/*.*
and
sudo rm /var/tmp/pamac/dbs/sync/*.*
then
sudo pacman -Syu.

2 Likes

additional … you could first update the mirrors
sudo pacman-mirrors -f5 && sudo pacman -Syyu

2 Likes

If I recall correct - the folder /var/tmp/pamac/dbs is a symlink to /var/lib/pacman which should make the db.lck file available both places.

You specifically mention btrfs - so if this the lock file is not there you have a file system error and pamac will not be in sync with pacman - which is the intention of the symlink - and it is likely to cause weird inconsistencies between pamac and pacman - depending on the version of the database they are accessing.

1 Like