Unable to access the dpkg database directory in Endless

caminhante

New Member
Joined
Dec 11, 2021
Messages
2
Reaction score
0
Credits
19
Hi.

I just bought a new notebook with Linux Endless 3.8.0 installed.
I'm an old user of fedora but not much experienced in Debian distros.

I am trying to install Insync 3.6.1 deb packag and used the command:
sudo dpkg -i insync_3.6.1.50206-impish_amd64.deb
As result I received the following error message:
dpkg: error: unable to access the dpkg database directory /var/lib/dpkg: read only file system

How can I solve this?
 


The error makes it sound as if the file-system has been put into read-only mode - which could mean you may have a problem with your HD/SSD. But that would be the worst-case scenario....

However, I think it's more likely to be related to dpkg having an active lock on it.
Most likely because of something else that is running which is using apt, or dpkg (Like automatic updates?!), or perhaps a previous apt, or dpkg operation that failed, or was interrupted before it finished and the dpkg lock was not automatically removed.

In the first case - (automatic updates are using apt/dpkg and dpkg is locked):
The best thing to do is to wait for the automatic update process to finish. At which point the dpkg lock will be removed and you'll be able to use apt/dpkg again.
This scenario is why I disabled automatic updates on my Debian machine. The bloody updates always seemed to be running at the exact same time that I wanted to install, or uninstall something and the dpkg lock would be active. So that's one possible explanation/fix.

If you've ruled out automatic updates being the culprit - to diagnose the other likely scenario - apt/dpkg failed, or was interrupted before it finished a previous operation and the lock is still in place:
See if the following file exists: /var/lib/dpkg/lock
And if it does, simply remove it:
sudo rm /var/lib/dpkg/lock
That should remove the lock-file and should allow apt/dpkg to install the package.
After removing the lock-file, use apt to install the package instead of dpkg.

BTW - On Debian based distros - when installing third party packages that are not from the native repositories of your installed distro, it's better to use apt to install them, rather than dpkg. Because apt can handle complex dependency chains better than dpkg. apt is easier to use and uses dpkg internally.

So after downloading a 3rd party .deb package (be careful where you download 3rd party packages from though! Don't download them from any old place. Make sure it's from a reputable site!)
The best way of installing is:
sudo apt install /path/to/yourpackage.deb
Where /path/to/yourpackage.deb is the path/filename of the locally downloaded .deb file that you want to install. Apt doesn't only download and install packages via the internet - it can also install packages that you have held locally.

So to sum up:
1. Check if any automatic updates are running - if they are - then wait until they're finished.
if not:
2. Check for the existence of the file /var/lib/dpkg/lock and remove it, then try installing your package again using apt.
If neither of the above fixes the problem - then it may be something more complex and we have more digging to do.
 
The error makes it sound as if the file-system has been put into read-only mode - which could mean you may have a problem with your HD/SSD. But that would be the worst-case scenario....

However, I think it's more likely to be related to dpkg having an active lock on it.
Most likely because of something else that is running which is using apt, or dpkg (Like automatic updates?!), or perhaps a previous apt, or dpkg operation that failed, or was interrupted before it finished and the dpkg lock was not automatically removed.

In the first case - (automatic updates are using apt/dpkg and dpkg is locked):
The best thing to do is to wait for the automatic update process to finish. At which point the dpkg lock will be removed and you'll be able to use apt/dpkg again.
This scenario is why I disabled automatic updates on my Debian machine. The bloody updates always seemed to be running at the exact same time that I wanted to install, or uninstall something and the dpkg lock would be active. So that's one possible explanation/fix.

If you've ruled out automatic updates being the culprit - to diagnose the other likely scenario - apt/dpkg failed, or was interrupted before it finished a previous operation and the lock is still in place:
See if the following file exists: /var/lib/dpkg/lock
And if it does, simply remove it:
sudo rm /var/lib/dpkg/lock
That should remove the lock-file and should allow apt/dpkg to install the package.
After removing the lock-file, use apt to install the package instead of dpkg.

BTW - On Debian based distros - when installing third party packages that are not from the native repositories of your installed distro, it's better to use apt to install them, rather than dpkg. Because apt can handle complex dependency chains better than dpkg. apt is easier to use and uses dpkg internally.

So after downloading a 3rd party .deb package (be careful where you download 3rd party packages from though! Don't download them from any old place. Make sure it's from a reputable site!)
The best way of installing is:
sudo apt install /path/to/yourpackage.deb
Where /path/to/yourpackage.deb is the path/filename of the locally downloaded .deb file that you want to install. Apt doesn't only download and install packages via the internet - it can also install packages that you have held locally.

So to sum up:
1. Check if any automatic updates are running - if they are - then wait until they're finished.
if not:
2. Check for the existence of the file /var/lib/dpkg/lock and remove it, then try installing your package again using apt.
If neither of the above fixes the problem - then it may be something more complex and we have more digging to do.
Thank you for your answer @JasKinasis

Unfurtunatelly that did not worked coz the lock file is also protected.

$ sudo rm /var/lib/dpkg/lock
rm: cannot remove 'lock': read only file system

Also, I add this information:

$ mount | grep /var
/dev/nvme0n1p3 on /var type ext4 (rw,relatime,errors=remount-ro)

:confused:

Any other tips?
 
Last edited:
Thank you for your answer @JasKinasis

Unfurtunatelly that did not worked coz the lock file is also protected.



Also, I add this information:



:confused:

Any other tips?

OK, that’s basically the worst case scenario. That usually means some kind of error occurred with the file-system and it’s been mounted in read-only mode to protect it from further damage, or to prevent you losing data.
I’d recommend backing up everything on that drive (including any other partitions/file systems that are on there). Then it might be an idea to take a look at your system logs, to see if you can work out what’s happened.
It’s been a long while since I’ve had to diagnose these kinds of problems on any of my machines. Not sure what to suggest offhand!
 
Running fsck on the drive may be worth doing. I'd do it from outside the OS, with a live USB.

 

Staff online

Members online


Top