[SOLVED] du and fd commands give contradictory outputs
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have an Ubuntu Server 12.04 LTS (64bit version),
My filesystem is organized in partitions and one of them is used for logging purposes (/dev/sdb mounted on /var/log).
Somehow when I run df I get information that my log partition is at 100 of its 7GB capacity and by running du I find it is only using a few hundred kB, it makes no sense.
Even when I'm just listing the /var/log content with 'ls -lh' I do not find many files:
du only lists files which are in directories. Anonymous files are not listed. For example if a program has a file open which has been unlinked from any directory then it will not be counted.
du only lists files which are in directories. Anonymous files are not listed. For example if a program has a file open which has been unlinked from any directory then it will not be counted.
But I also tried 'ls -lh' and didn't find any big files nor a large collection of smaller files.
I really don't know what is taking so much space in my /var/log partition and I'm afraid it might affect the server's performance.
I even tried a reboot to see weather it would make a difference, but it remained the same
I notice you used the "-x" (--one-file-system) option in your du command. Is there actually anything mounted anywhere under /var/log ? That seems unusual, bit if so, you could have files hidden under that active mount point. If not, then "fsck -f /dev/sdb" would be in order.
I notice you used the "-x" (--one-file-system) option in your du command. Is there actually anything mounted anywhere under /var/log ? That seems unusual, bit if so, you could have files hidden under that active mount point. If not, then "fsck -f /dev/sdb" would be in order.
Hey!
Thanks for your advice, but I have no mount points within /var/log.
How can I check for hidden files?
I've tried "fsck -f /dev/sdb" and it identified/corrected a few issues:
several "Free blocks count wrong (98036, counted=1769110)"
Orphaned inodes
The result from fsck:
Code:
/dev/sdb: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sdb: 44/458752 files (11.4 non-contiguous), 65898/1835008 blocks
The partition remains accusing 100
Yet, after another reboot, it went to 4% used which is the correct value
Yet, after another reboot, it went to 4 used which is the correct value
This is because when a file is 'deleted' (aka unlinked), the entry disappears from the inode (dir), but the storage is only returned to the system when ALL processes that have it open have relinquished the file. If any process has the file open, it will continue to take up space.
df 'sees' the file space usage as still there, du doesn't.
Its a very common qn/soln and you'll see a lot of hits on google for it.
You can easily test it yourself by writing a small prog that writes to a test file and the 'delete' the file manually from another terminal.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.