Inkonsistente du-Ausgabe auf /usr

Inkonsistente du-Ausgabe auf /usr

Hier ist zunächst die Größe von /usr:

$ sudo du -sh /usr
6.2G    /usr
$

Wenn ich einen duauf die Verzeichnisse am ausführe /und auswähle /usr, erhalte ich Folgendes:

$ sudo du -sh /*/ | grep /usr
du: cannot access '/proc/1800845/task/1800845/fd/4': No such file or directory
du: cannot access '/proc/1800845/task/1800845/fdinfo/4': No such file or directory
du: cannot access '/proc/1800845/fd/3': No such file or directory
du: cannot access '/proc/1800845/fdinfo/3': No such file or directory
2.5G    /usr/
$

EDIT0: /*/ wird erweitert:

$ sudo du -sh /bdd/ /bin/ /boot/ /data/ /dev/ /etc/ /home/ /lib/ /lib32/ /lib64/ /libx32/ /lost+found/ /media/ /mnt/ /opt/ /proc/ /root/ /run/ /sbin/ /snap/ /srv/ /sys/ /tmp/ /usr/ /var/ / | grep /usr
du: cannot access '/proc/1807041/task/1807041/fd/4': No such file or directory
du: cannot access '/proc/1807041/task/1807041/fdinfo/4': No such file or directory
du: cannot access '/proc/1807041/fd/3': No such file or directory
du: cannot access '/proc/1807041/fdinfo/3': No such file or directory
2.5G    /usr/
$ \ls -ld /lib /lib32 /lib64 /libx32
lrwxrwxrwx 1 root root  7 Mar 17  2023 /lib -> usr/lib
lrwxrwxrwx 1 root root  9 Mar 17  2023 /lib32 -> usr/lib32
lrwxrwxrwx 1 root root  9 Mar 17  2023 /lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Mar 17  2023 /libx32 -> usr/libx32
$ \ls -ld /lib/ /lib32/ /lib64/ /libx32/
drwxr-xr-x 98 root root 4096 Jan 30 06:25 /lib/
drwxr-xr-x  2 root root 4096 Mar 17  2023 /lib32/
drwxr-xr-x  2 root root 4096 Jan 11 06:22 /lib64/
drwxr-xr-x  2 root root 4096 Mar 17  2023 /libx32/
$ sudo du -xsh /lib/
3.5G    /lib/
$

Warum ist dudie Ausgabe inkonsistent?

Antwort1

duzählt jede Datei nur einmal, auch wenn sie mehrfach gefunden wird.

Der erste Befehl wählt aus /bin, was heutzutage im Allgemeinen einSymlinkzu /usr/binund daher sind /bin InhalteAuch/usr-Inhalte. Da diese Dateien in der Liste an erster Stelle stehen, werden sie /bin zugeordnet, wenn sie zuerst gefunden werden, und bei der nächsten Messung von /usr ignoriert.

Beispiel – beachten Sie, dass die Gesamtsumme in beiden Fällen 23 G beträgt:

# du -hsc /usr/
23G     /usr/
23G     total

# du -hsc /bin/ /usr/
2.6G    /bin/
20G     /usr/
23G     total

# ls -ld /bin /usr
lrwxrwxrwx 1 root root   7 Jan 19 19:10 /bin -> usr/bin/
drwxr-xr-x 1 root root 112 Feb 20 07:23 /usr/

verwandte Informationen