I have an Ubuntu 20.04 server installed on a single 8GB drive. The default installation has some "snap"s installed also. So, there are some "squashfs" file systems also reported by the df
command:
# df -mT
Filesystem Type 1M-blocks Used Available Use% Mounted on
/dev/root ext4 7877 1837 6025 24% /
devtmpfs devtmpfs 465 0 465 0% /dev
tmpfs tmpfs 477 0 477 0% /dev/shm
tmpfs tmpfs 96 1 95 1% /run
tmpfs tmpfs 5 0 5 0% /run/lock
tmpfs tmpfs 477 0 477 0% /sys/fs/cgroup
/dev/loop0 squashfs 18 18 0 100% /snap/amazon-ssm-agent/1566
/dev/loop1 squashfs 94 94 0 100% /snap/core/9066
/dev/loop2 squashfs 55 55 0 100% /snap/core18/1705
/dev/loop3 squashfs 69 69 0 100% /snap/lxd/14804
/dev/loop4 squashfs 70 70 0 100% /snap/lxd/14890
/dev/loop5 squashfs 55 55 0 100% /snap/core18/1754
tmpfs tmpfs 96 0 96 0% /run/user/1000
As you see, there is only 1837MB of data stored in the (only) disk.
Now, I am trying the list that disk usage for each directory present under root (/
) using the following command:
# du -smc /* 2>/dev/null
0 /bin
48 /boot
0 /dev
8 /etc
1 /home
0 /lib
0 /lib32
0 /lib64
0 /libx32
1 /lost+found
1 /media
1 /mnt
1 /opt
0 /proc
1 /root
1 /run
0 /sbin
1116 /snap
1 /srv
0 /sys
1 /tmp
1166 /usr
601 /var
2938 total
The output shows a large amount of disk space used by the /snap
directory, which of course is not true.
What is the correct way to count the size of files residing only on "real disk" filesystems? Adding the option -x
to du
does not make me feel comfortable, because in the future I may have another "real disk" filesystem mounted under /home
for example and I do want that to be counted in du
's output.