Operating System - HP-UX
1827284 Members
3575 Online
109717 Solutions
New Discussion

Discrepancy is disk usage

 
SOLVED
Go to solution
Praveen Bezawada
Respected Contributor

Discrepancy is disk usage

Hi
When I do du -ks /opt it gives 2153590
When I do df -k /opt its gives
3223552 allocated
0 free
3223552 used
100% allocation used.
So on a 3GB file systems though du say only 2GB is used df say 3GB is used. Why is this diescrepancy.
Actually I have deleted some files of total 1 GB a little while ago. Has this caused the problem.
Please help
Thanks in advance
Praveen
6 REPLIES 6
Paula J Frazer-Campbell
Honored Contributor

Re: Discrepancy is disk usage

Hi
Drop to a single user status and try:-
fuser -u /dev/VG??/opt
and look to see if any areas are locked.

See also man fuser.

Paula
If you can spell SysAdmin then you is one - anon
Dan Hetzel
Honored Contributor

Re: Discrepancy is disk usage

Hi,

Discrepancies between 'du' and 'df' will happen if the directory isn't a mount point or if there are mount points below it.

With a standard installation, /opt should be a separate filesystem, so, as far as there are no filesystems mounted below /opt, 'du' and 'df' should report the same figures.

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Rainer_1
Honored Contributor

Re: Discrepancy is disk usage

think you have additional mount points in /opt (NFS or lvols) so that du walks thru different filesystems.
Use

du -sxk /opt

this will not go to any other mount point within /opt and the result should be the same as df -k /opt
Byron Myers
Trusted Contributor
Solution

Re: Discrepancy is disk usage

Even though a file is deleted, there may still be open file handles on it. If this is the case, then "df" will not report the file as being deleted. If you know what process(es) were using the deleted file(s), then they will have to close the handles, or you will have to end or kill them. Only when the file handles are cleared from the file table will df report accurately.
If you can focus your eyes far and straight enough ahead of yourself, you can see the back of your head.
Bill Hassell
Honored Contributor

Re: Discrepancy is disk usage

There may be another explanation: sparse files. A sparse file is one that has been created with 'holes' or unwritten parts. Consider writing a file with record #1, then by seeking to record one million, writing another record and then closing the file. The file has but two records and occupies only a couple of blocks but the missing parts are not stored nor counted in bdf(1) or du(1). Depending on the size of the file and the spareseness, the difference in apparent versus actual size may be quite large.

It is possible to create a sparse file with:

dd if=/etc/issue of=/var/tmp/sparse bs=2048k seek=1

where you will see the original file is just a few dozen bytes, the result with ls -l or wc -c shows a 2 meg file, but du(1) will show the file as occupying just a bit more than the original /etc/issue file. A cp(1) of the file will create a new file that is the same size (using ls -l or wc -c) but du(1) will now show a much larger size.

A common file that is often sparse is a core file from a crashed program. Another file that might be sparse is /etc/mail/aliases.pag. And of course, any programmer could write special code that creates a sparse file.


Bill Hassell, sysadmin
Steffi Jones_1
Esteemed Contributor

Re: Discrepancy is disk usage

Hi,

the space is not released yet. This can happen when you try to remove active files.
A reboot will clean this up or if you can find the process which was using the files you might be lucky by killing the process that it will release the space.

This might be tricky and I would recommedn the usage of the shareware program lsof for this.

But in anycase a reboot will help you,

Steffi jones