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?

  • Version of CentOS? Filesystem type? – ewwhite Aug 9 '12 at 16:37
  • Did you run du as root? – mgorven Aug 9 '12 at 17:07
  • CentOS 5.8, file-system, ext3 file-system, and running as root – Farhan Aug 9 '12 at 17:08

See if you have any deleted files still in use

lsof | grep deleted
  • it shows long list of files – Farhan Aug 9 '12 at 17:14
  • those are your files that are still taking up space but deleted.. so if you restart the process that has them open space will free up – Mike Aug 9 '12 at 17:24

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.

  • 1
    my actual concern is to find that where my space is gone? – Farhan Aug 9 '12 at 17:03

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.

  • my actual concern is to find that where my space is gone? – Farhan Aug 9 '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 9 '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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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