Operating System - HP-UX
1823065 Members
3050 Online
109645 Solutions
New Discussion юеВ

Difference between "LS" and "du" sizes.

 
Ty Roberts
Frequent Advisor

Difference between "LS" and "du" sizes.

One of our DBA's created a "locally managed" temp file (that is his description) of 30GB. If you looked at the "ls -l" or "ll" stats on the file it shoed up the full 30GB

========ll listing ===========
# ll temp_adhoc01.dbf
-rw-r----- 1 oracle dba 31457288192 Oct 24 09:51 temp_adhoc01.dbf
==============================

But according to a bdf or a du, the space had not been allocated in the filesystem.

========== du output ==============
# du -sk temp_adhoc01.dbf
72 temp_adhoc01.dbf
===================================

Once he ran a query against the table the DU size started to grow but it still did not get up to the 30GB.

Why would the LL show it as the fully allocated size, but the DU size (and through a DF or bdf command for that matter) it is now showing up as used in the filesystem.

I know I had seen something like this in the ITRC before but something must be up with searching because none of my searches came back with anything. So I appologize for posting an already answered question if that is the case.

Thanks,
Ty
8 REPLIES 8
Pete Randall
Outstanding Contributor

Re: Difference between "LS" and "du" sizes.

Ty,

Sounds like a sparse file to me. See the man page for pre-alloc and the following thread for additional details:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=690868


Pete

Pete
Ty Roberts
Frequent Advisor

Re: Difference between "LS" and "du" sizes.

Pete, thanks for the quick response.

Whatever problem I was having with my ITRC searches stopped and I was able to get some data back and find info on sparse files.

Here is a more interesting question. If the sparse file on 30GB is made, will the Filesystem know that there is 30GB out there that it can not give to anyone even though BDF's and du's don't show it as used??
Pete Randall
Outstanding Contributor

Re: Difference between "LS" and "du" sizes.

Ty,

Good question and one that I don't have an answer for. I would do a little experimentation and try either prealloc'ing another file or copying a big file to see if it's allowed.


Pete

Pete
Arunvijai_4
Honored Contributor

Re: Difference between "LS" and "du" sizes.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=948503

This thread contains lot of information.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Rodney Hills
Honored Contributor

Re: Difference between "LS" and "du" sizes.

I don't think the file system is that sophisticated to have "reserved" pointers.

The 30GB is the highest address, not space allocated, so it is possible if you write into the middle of the file, their may not be space available if other files file up the file system.

My 2 cents

Rod Hills
There be dragons...
Hanwant Verma_1
Regular Advisor

Re: Difference between "LS" and "du" sizes.

Hi

The difference is due to sparse files. These are files that are only partially populated with data. bdf shows the directory structure
info which includes data areas that could be occupied if the areas were filled in. du shows the actual space. If you copy the /home directory to another location, the sparse files will be filled in and then bdf and du will agree.

Hanwant
Ty Roberts
Frequent Advisor

Re: Difference between "LS" and "du" sizes.

Thanks guys. I am going to work with the DBA's later today to run some tests. I tried to create a sparse file using the "prealloc" command, but that looked as though it allocated ALL the space within the filesystem. So I can't test with that. I will post my results after our testing today...

Thanks
James R. Ferguson
Acclaimed Contributor

Re: Difference between "LS" and "du" sizes.

Hi Ty:

No, 'prealloc' won't create a sparse file. You need to do it with a small piece of C code or easier (isn't it always!) with perl:

# perl -e 'open(FH,">","sparsef");seek(FH,10**9,0);print FH "\n";close(FH) or die "$!\n"'

Adjust the value 10**9 to your taste. The above creates a sparse file of 10**9+1 bytes.

Regards!

...JRF...