0

I use df and du to check disk usage of centos,then I get different results from these tools.

[root@localhost home]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/cl-root xfs 149G 31G 119G 21% / devtmpfs devtmpfs 32G 0 32G 0% /dev tmpfs tmpfs 32G 0 32G 0% /dev/shm tmpfs tmpfs 32G 41M 32G 1% /run tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup /dev/vda1 xfs 1014M 178M 837M 18% /boot tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/1000 tmpfs tmpfs 6.3G 16K 6.3G 1% /run/user/1001 [root@localhost /]# du -sh / 2>/dev/null 7.0G /

However, I've rebooted the system several times and make sure that there is no big file deleted and recalculated.

This problem is really confused me for tow days,so I want to know if there is any way I can find out which blocks of disk is used? If yes,I can get where the missed 23.3Gs gone ?

[root@localhost home]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 150G 0 disk ├─vda1 252:1 0 1G 0 part /boot └─vda2 252:2 0 149G 0 part ├─cl-root 253:0 0 148.6G 0 lvm / └─cl-swap 253:1 0 412M 0 lvm [SWAP]

Yvette Yu
  • 1
  • 1
  • 1
    What filesystem? Please [edit] the question (provide output of `mount` maybe). Example: I mount a certain subvolume of Btrfs on `/`. `du` works on file level and sees only this subvolume. There are other subvolumes that take space and `df` reflects this. – Kamil Maciorowski Feb 13 '19 at 05:44
  • 1
    Related: [How to analyse disk usage in command line Linux?](https://superuser.com/q/300606/150988), [du vs df output](https://superuser.com/q/289678/150988), [Linux filesystem; difference in calculating size using df & du](https://superuser.com/q/304391/150988), [Difference between "df -k" and "du -sh"](https://superuser.com/q/279497/150988), and [Discrepancy between df and du](https://superuser.com/q/581496/150988). – Scott - Слава Україні Feb 13 '19 at 05:57

1 Answers1

0

After cleaned up disk fragmentation with xfs_fsr,the missing disk space came back!

[root@localhost /]# xfs_db -c frag -r /dev/mapper/cl-root actual 430606, ideal 421725, fragmentation factor 2.06% Note, this number is largely meaningless. Files on this filesystem average 1.02 extents per file [root@localhost /]# xfs_fsr /dev/mapper/cl-root / start inode=0 [root@localhost /]# xfs_db -c frag -r /dev/mapper/cl-root actual 428060, ideal 421496, fragmentation factor 1.53% Note, this number is largely meaningless. Files on this filesystem average 1.02 extents per file [root@localhost /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 149G 7.0G 142G 5% / devtmpfs 32G 0 32G 0% /dev tmpfs 32G 0 32G 0% /dev/shm tmpfs 32G 41M 32G 1% /run tmpfs 32G 0 32G 0% /sys/fs/cgroup /dev/vda1 1014M 178M 837M 18% /boot tmpfs 6.3G 0 6.3G 0% /run/user/1000 [root@localhost /]# du -sh 6.8G . [root@localhost /]#

Yvette Yu
  • 1
  • 1