Updating disk free size without rebooting the host
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.
Related videos on Youtube
Comments
-
Kannan Mohan over 1 year
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 ?
-
Mat over 11 yearsYou 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.
-
-
Nuno Pereira about 8 yearsBetter call lsof with ’lsof +L1’ which shows deleted files. Made an edit suggestion
-
faressoft over 6 yearsSo how to close them ?
-
subtleseeker about 3 yearsCheck this to close them: unix.stackexchange.com/a/182244/249938