0

Ok, here's the issue which is totally confusing to me:

df -h
Dateisystem          Größe Benut  Verf Ben% Eingehängt auf
/dev/sda2             3,8G  1,5G  2,2G  41% /
/dev/sda1             122M   13M  103M  11% /boot
tmpfs                1014M     0 1014M   0% /dev/shm
/dev/sdb1            1016M  866M  150M  86% /srv

However:

du -hs /srv
55M     /srv

Just for information:

mount | grep srv
/dev/sdb1 on /srv type xfs (rw)

The 86% gave me a warning email (which is intended) after which I deleted ~800MB of files under /srv. This was a few hours ago.

Using du, I get what I consider the correct amount of data on that partition. However, df doesn't seem to get that. Why? (This is somewhat annoying, because I still get regular warning emails based on that output.)

Not sure if that's important, but I'm on a server using CentOS release 5.11 (Final).

cas
  • 78,579
Thomas
  • 123
  • If the files are still open by an application the disk space won't be freed until the process ends. Find out what's using /srv and stop/restart them. – mkomarinski May 26 '16 at 12:29
  • Ok, that was it. One of the files was a logfile and I didn't restart the service that used it - didn't know I needed to. Thanks a lot for the quick and correct answer!! :) Should I close/delete this question? If so, how? – Thomas May 26 '16 at 12:41
  • did the 800MB of files you deleted include large logfiles and/or other open files? these files wont actually be deleted until they are closed (this often means restarting the syslogd or whatever program still has them open) – cas May 26 '16 at 12:55

2 Answers2

1

df counts the file system allocated blocks, du use the size information of each files. A difference can have many cause:

1) Unlinked (deleted) files that are still open by application. lsof +aL1 <filesystem> will helps you to identfy the processes.

2) Files beneath mount points hidden to du. debugfs can helps you.

$ sudo debugfs 
debugfs 1.42.12 (29-Aug-2014)
debugfs:  open /dev/<the / file system  device>
debugfs:  cd /boot
debugfs:  ls -l 
 1966081   40755 (2)      0      0    4096 26-May-2016 16:28 .
      2   40555 (2)      0      0    4096 11-May-2016 10:43 ..
 1974291  100644 (1)      0      0       0 26-May-2016 16:28 bob   <---<<< /boot/bob is hidden by /boot fs

3) Sparse files that looks bigger than the reality. non allocated blocks are not counted by df but they are counted in the file size.

Note that Hard links do not fools du

Emmanuel
  • 4,187
0

If files are still open by an application the disk space won't be freed until the process ends. Find out what's using /srv and stop/restart them