A system crash at an inopportune time left my file system in a corrupted state. Fixing it up with fsck(1) worked just fine but made a subsequent system upgrade fail with an unusual error:
dpkg: error processing /var/cache/apt/archives/libfoo-1.2.3_amd64.deb (--unpack):
unable to install (supposed) new info file `/var/lib/dpkg/tmp.ci/symbols': Operation not permitted
The directory /var/lib/dpkg/tmp.ci
did not exist. Creating it manually and re-running
the upgrade failed exactly the same way (and removed the directory again.)
Internet searches didn't turn up useful answers. People have been running into this error since at least 1998 but no solutions were presented except reformat and reinstall.
strace(1) showed that dpkg(1) errored when it tried to access a file called
/var/lib/dpkg/info/libfoo-1.2.3:amd64.symbols
. The file was there but had
the telltale signs of file system corruption:
- Bogus group ID
- Bogus file attributes printed by lsattr(1)
- rm, mv, chown, chattr, etc. all failed with "Operation not permitted", even as root
- stat(1) printed the inode but debugfs(8) insisted no such inode existed
Since I couldn't delete or move the file, I solved my problem as follows:
- Move
/var/lib/dpkg/info
out of the way, then recreate it with mkdir(1) - Copy all files except the problematic one back to
/var/lib/dpkg/info
- Run
apt --fix-broken install
- Resume the upgrade