Many files in /var/lib/dpkg/info/ corrupted; how to recover
In my case i got a lot of *.list files corrupted. If you do
file /var/lib/dpkg/info/<package_name>.list
you should usually get:
/var/lib/dpkg/info/<package_name>.list: ASCII text
but if your list files are corrupted you will get:
/var/lib/dpkg/info/<package_name>.list: data
I made two scripts to fix this problem.
The first script check for this and rename each corrupted .list file into *.list.broken
The second script cycle for each *.list.broken file and force reinstallation of the package.
sometimes the install fails because of problems with triggers:
fgets gave an empty string from '/var/lib/dpkg/info/libnih1:amd64.triggers'
in that case you have to move/rename that file like:
mv /var/lib/dpkg/info/libnih1:amd64.triggers /var/lib/dpkg/info/libnih1:amd64.triggers.broken
Hope this helps someone facing the same mess.
Related videos on Youtube
Comments
-
bguiz over 1 year
When I run
sudo apt-get (anything)
, I invariably get this error:dpkg: unrecoverable fatal error, aborting: files list file for package 'thunderbird-gnome-support' is missing final newline E: Sub-process /usr/bin/dpkg returned an error code (2)
After some Googling, I learn that this is because
/var/lib/dpkg/info/thunderbird-gnome-support.list
is corrupt. Icat
that file, and it most certainly is corrupt - it should be a plain text file containing a list of absolute file paths, but instead is a binary file.Now I inspect the other files in the same directory, and it appears that many of them are corrupt in the same way. This indicates that something went severely wrong in my file system, that caused many files to get corrupted. Unfortunately, it happened to affect system files.
How do I recover from this?
More details:
Just prior to this, I installed a routine update when Ubuntu prompted me. It was a new Linux kernel, and some system file headers.
After restarting, these were my specs:
OS specs:
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 13.10 Release: 13.10 Codename: saucy $ uname -a Linux brendang-linux 3.11.0-24-generic #41-Ubuntu SMP Mon Jun 9 20:36:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Immediately after restarting for the first time, the entire file system appeared to be mounted as read only (which has not been the case previously). Subsequently I have had to reboot several times before the system worked. I have done
touch /forcefsck
in between them to ensure thatfsck
runs, and am not sure what else needs to be done.-
Admin about 9 yearsHave same problem. Did you resolve this?
-
-
Julián Landerreche almost 4 yearsI was having the same exact issue OP reported. Your solution helped me recovering from this situation (on Debian Sid). I'm still planning to do a full OS reinstall though. I still wonder what might have caused all these files getting corrupted. I think it could have been my SSD going badly or a bad dpkg release.
-
TheTechRobo Stands for Ukraine almost 4 yearsThank you for showing to use
file
-- I didn't even know it existed!! I just ranmv <NAME>.list <NAME>.list.BINARY
for each (3) binary files. These were in/etc/apt/sources.list.d
(and runningnano
on them just showed a bunch of^@
's). Then I just rancp <NAME>.list.save <NAME>.list
and it seems to work! :D -
TheTechRobo Stands for Ukraine almost 4 yearsYe, it's working :D