Operating System - HP-UX
1832678 Members
2992 Online
110043 Solutions
New Discussion

Discrepancy between bdf, df and ls

 
SOLVED
Go to solution
Suren Selva
Advisor

Discrepancy between bdf, df and ls

Hello All,

We have a 5 GB filesystem /oradata1 that is 80% full. We have 1 GB free. Our Oracle DBA created a 2 GB *.dbf file. How is this possible?

When I go into the directory /oradata1/oradata/some_instance and do an ll the file temp01.dbf is 2 GB in size.

However when I do a "du -ks *" in /oradata1/oradata/some_instance directory I get the size of temp01.dbf as 72 KB.

A bdf still shows 80% usage. So does df -k. Does anyone know the cause of this discrepancy?

Thanks in advance to all replies.

Regards,
Suren Selva

Experience is worth nothing if not gained from!
1 REPLY 1
Bill Hassell
Honored Contributor
Solution

Re: Discrepancy between bdf, df and ls

Answer: sparse files (very common question). Oracle creates only a few parts of the file at random file positions, the rest of the file is undefined. 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 VERY large.

Create your own 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 than the original file.

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