8

On my CentOS server, both of the commands are showing different usage for disk / , df shows this output:

Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2             16G   14G  952M  94% /
/dev/xvda6            996M  258M  687M  28% /tmp
/dev/xvda3             16G  6.5G  8.3G  45% /var
/dev/xvda1            251M   25M  213M  11% /boot
tmpfs                 4.0G     0  4.0G   0% /dev/shm

and du -sh shows

6.9M    /bin/
15M /boot/
123M    /etc
212K    /home/
233M    /lib
27M /lib64/
16K /lost+found/
8.0K    /media/
8.0K    /mnt/
399M    /opt/
959M    /root/
35M /sbin/
8.0K    /srv/
0   /sys/
2.5G    /usr/
4.2G    total

Also tried with NCDU tool, which reports only 5.6GB usage.

How to find hidden disk space?

Farhan
  • 4,210
  • 9
  • 47
  • 76

3 Answers3

12

See if you have any deleted files still in use

lsof | grep deleted
Mike
  • 21,910
  • 7
  • 55
  • 79
1

There's a lengthy explanation to be found in any number of blogposts online with a quick search, but the basic gist is this:

If I create a 1 GB sparse file, du will show 1 GB, but df will show zero usage. If I have a 1 GB file open in some program and delete it, df will still show 1 GB of usage until all references to the inode are closed, but du will never find the file to display it.

Jeff Ferland
  • 20,239
  • 2
  • 61
  • 85
0

df is file system usage which includes files, and other structures that support the files such as journal etc. du only shows the file size sum which will mostly be less. the difference will depend how long the filesystem has been in use, the filesystem itself, etc.

johnshen64
  • 5,747
  • 23
  • 17
  • my actual concern is to find that where my space is gone? – Farhan Aug 09 '12 at 16:47
  • yes, your space went to file system overhead. if you reboot your server, the difference is likely to decrease. or you can use a filesystem with less overhead, but more limited such as ext2. – johnshen64 Aug 09 '12 at 16:59
  • @johnshen64 - 10 GB is a bit too much file system overhead! What you suggest is to move backward to non-journal filesystem, which on its turn will invoke all sorts of troubles. IIRC, the journal size is negligible against the file system size and could practically be excluded from the equation. – grs Aug 12 '12 at 19:52