24

I use RHEL4 with LVM2 on it. At times even after removing large files more than a GB, the partition size is not getting updated when using the df command.

-bash-3.00$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/sys-root  3.9G  1.4G  2.3G  39% /
/dev/cciss/c0d0p1     251M   19M  219M   8% /boot
/dev/mapper/sys-home  250G  125G  113G  53% /home
/dev/mapper/sys-tmp   3.9G   41M  3.7G   2% /tmp
/dev/mapper/sys-var   3.9G  3.6G   98M  98% /var

But when I check using du it shows the proper size

-bash-3.00$ sudo du -sh /var/
 179M   /var/

you can see there that the df output shows /var partition to be 3.6Gb used but the du shows that its just only 179Mb.

Now the problem is that neither sync or partprobe is not updating the information. But surely rebooting the host will resolve the issue. But as this is a production server I cannot reboot it. Is there any way that I can update the disk information manually without rebooting the host ?

1
  • 1
    You probably have open deleted files (i.e. processes that are holding on to deleted files). Try something like lsof to find out. Used/avail isn't stored in the partition table, partprobe (or any type of partition re-read) won't help at all.
    – Mat
    Jan 12, 2013 at 17:30

1 Answer 1

30

When a file is removed/deleted/unlinked, if it is still held open by any process then only the directory entry for the file is erased, not the file's data. When the file is completely closed by all processes the data is returned to the free space pool. It's a feature since you can have anonymous files this way.

To see if you have any open deleted file on a filesystem, run one of these commands, where /mount/point is the mount point (/var in your case):

lsof +L1 /mount/point

This article on open, unlinked files should help explain this some more.

4
  • 2
    I was deleting logs but df didn't show any freed space until I restarted the server processes. Thanks!
    – fet
    Jun 6, 2014 at 2:44
  • Better call lsof with ’lsof +L1’ which shows deleted files. Made an edit suggestion Feb 10, 2016 at 2:52
  • 1
    So how to close them ?
    – faressoft
    Oct 18, 2017 at 8:12
  • Check this to close them: unix.stackexchange.com/a/182244/249938 Mar 9, 2021 at 4:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .