0

My server has a 130 GB Volume attached.

To check the free disk psace, I run df -h -x tmpfs -x squashfs | grep -v /run/shared and I get :

Filesystem      Size  Used Avail Use% Mounted on
udev            965M     0  965M   0% /dev
/dev/xvda1      128G  111G   13G  90% /

However, when I want the details of the disk usage, by running ncdu on the root directory, I get :

.  55,7 GiB [######### ] /home                                                                                                                           
.  24,0 GiB [####      ] /var
.   2,4 GiB [          ] /usr
    1,0 GiB [          ]  swapfile
  598,6 MiB [          ] /lib
   63,0 MiB [          ] /boot
    9,4 MiB [          ] /sbin
    9,1 MiB [          ] /bin
.   8,1 MiB [          ] /etc
.   4,3 MiB [          ] /tmp
.   2,7 MiB [          ] /run
!  24,0 KiB [          ] /root
!  16,0 KiB [          ] /lost+found
    4,0 KiB [          ] /lib64
e   4,0 KiB [          ] /opt
e   4,0 KiB [          ] /mnt
e   4,0 KiB [          ] /media
!   4,0 KiB [          ] /gandi
.   0,0   B [          ] /proc
.   0,0   B [          ] /sys
    0,0   B [          ] /dev
@   0,0   B [          ]  initrd.img.old
@   0,0   B [          ]  initrd.img
@   0,0   B [          ]  vmlinuz.old
@   0,0   B [          ]  vmlinuz
e   0,0   B [          ] /srv

There is a difference of about 27 GB with the free disk space returned by the previous command (111 GB).

Where does this difference come from ?

Thanks.

0

1 Answer 1

1

This question comes up quite often. The short answer is du and df use differect methods to get data.

The file system allocates disk blocks in the file system to record its data. This data is referred to as metadata which is not visible to most user-level programs (such as du). Examples of metadata are inodes, disk maps, indirect blocks, and superblocks.

The du command is a user-level program that isn't aware of filesystem metadata, while df looks at the filesystem disk allocation maps and is aware of file system metadata. df obtains true filesystem statistics, whereas du sees only a partial picture.

1
  • Thanks @4snok. I also have another difference between the calculation made by ncdu and a calculation made with PHP with the Flysystem package ? Apr 26 at 13:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.