After upgrading to Debian 12, duplicated files in /lib/x86_64-linux-gnu/ and /usr/lib/x86_64-linux-gnu/

I just upgraded my system from Debian 11 to 12, by following this guide from cyberciti. This system has been kept up-to-date for more than 9 years, so it has been through at least 4 major upgrades (Debian 7 or 8 to 12 today).

During the first run of apt upgrade --without-new-pkgs, I had an error about libudev (sadly I forgot to keep the output from the command), that I fixed by removing 2 files:

$ rm /lib/x86_64-linux-gnu/libudev.so.1 /lib/x86_64-linux-gnu/libudev.so.1.6.5

I was able to finish the upgrade and reboot.


By performing further investigation, it looks like my system has some other duplicated libraries:

$ dpkg --search /lib/x86_64-linux-gnu/perl/ /usr/lib/x86_64-linux-gnu/perl/
dpkg-query: no path found matching pattern /lib/x86_64-linux-gnu/perl/
libperl5.36:amd64: /usr/lib/x86_64-linux-gnu/perl

It looks like these directories are not symbolic links:

$ ls -ld /lib/ /lib/x86_64-linux-gnu/ /usr/ /usr/lib/ /usr/lib/x86_64-linux-gnu/
drwxr-xr-x 84 root root 4.0K Jul  5 21:05 /lib//
drwxr-xr-x 78 root root  96K Jul  5 21:05 /lib/x86_64-linux-gnu//
drwxr-xr-x 12 root root 4.0K Jul  5 20:32 /usr//
drwxr-xr-x 84 root root 4.0K Jul  5 21:05 /usr/lib//
drwxr-xr-x 78 root root  96K Jul  5 21:05 /usr/lib/x86_64-linux-gnu//

I already had a very similar issue before: Can’t restore systemd after upgrade from Debian 10 to 11: “undefined symbol: seccomp_api_get”


Here are the questions:

  1. Is it normal to have duplicated libraries in /lib/x86_64-linux-gnu/ and /usr/lib/x86_64-linux-gnu/
  2. Can I rely on the output of dpkg --search and delete the paths that show no path found …? Or can some tool help me clean this mess?
  3. What events on my system could have made this possible?

Update: actually it looks like there 2 directories are identical:

$ ls -lh /lib/x86_64-linux-gnu/test.ignore /usr/lib/x86_64-linux-gnu/test.ignore
ls: cannot access '/lib/x86_64-linux-gnu/test.ignore': No such file or directory
ls: cannot access '/usr/lib/x86_64-linux-gnu/test.ignore': No such file or directory
$ touch /lib/x86_64-linux-gnu/test.ignore
$ ls -lh /lib/x86_64-linux-gnu/test.ignore /usr/lib/x86_64-linux-gnu/test.ignore
-rw-r--r-- 1 root root 0 Jul  5 22:14 /lib/x86_64-linux-gnu/test.ignore
-rw-r--r-- 1 root root 0 Jul  5 22:14 /usr/lib/x86_64-linux-gnu/test.ignore

But I don’t understand how it works. And now I know that I must not delete files from /lib/x86_64-linux-gnu/ because it would delete files in /usr/lib/x86_64-linux-gnu/ too.

Asked By: A.L

||

If you want to see a symlink, you mustn’t add /:

ls -ld /lib

should show you a different result.

Debian 12 enforces a “merged /usr, the “duplication” you’re seeing is normal.

Answered By: Stephen Kitt

With the help of the answer from Stephen Kitt, here are the answers to my question:

  1. Is it normal to have duplicated libraries in /lib/x86_64-linux-gnu/ and /usr/lib/x86_64-linux-gnu/

Yes, there is a symlink:

$ ls -ld /lib /usr/lib
lrwxrwxrwx  1 root root    7 Jul  5 20:34 /lib -> usr/lib/
drwxr-xr-x 75 root root 4096 Jul  6 00:42 /usr/lib/
  1. Can I rely on the output of dpkg --search and delete the paths that show no path found …? Or can some tool help me clean this mess?

No, using dpkg --search on /lib only give irrelevant results, because some files are installed on /usr/lib/:

$ dpkg --search /lib/x86_64-linux-gnu/perl/cross-config-5.36.0/Config.pm 
/usr/lib/x86_64-linux-gnu/perl/cross-config-5.36.0/Config.pm
dpkg-query: no path found matching pattern /lib/x86_64-linux-gnu/perl/cross-config-5.36.0/Config.pm
libperl5.36:amd64: /usr/lib/x86_64-linux-gnu/perl/cross-config-5.36.0/Config.pm

Removing the file /lib/x86_64-linux-gnu/perl/cross-config-5.36.0/Config.pm would remove the file in /usr/lib, which can break the whole system.

  1. What events on my system could have made this possible?

As explained on the link shared by Stephen, the symlink from /lib to /usr/lib/ is normal on Debian 12.

Answered By: A.L
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.