Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Showing results for 
Search instead for 
Did you mean: 

detect sparse files

Valued Contributor

detect sparse files



due to my thread copy a filesystem best solution (local host or remote host)  i have a question about sparse files.


how can i find a sparse file ?


i am read following links :


Sparse files – what, why, and how

Oracle tempfile on linux is using sparse file by default


and found following perl script :


i test the perl and it  works for Linux not for HP-UX. i think the check depends on the blocksize of a directory or filesystem ?


we changed the script to

printf "blksize: $blksize \n";
my $blocks_used=$blocks*$blksize/8;

 because the $blksize is defined in Bit .


i made tests for HP-UX and Linux , the sparse will point out in every OS.


Also the Oracle Datafiles , which i think is true ?

in the attachments are the tests and the changed perl ( i add with extension '.sh' please change it to '.pl' , when you download it)




Valued Contributor

Re: detect sparse files

the checks are for all files right, but only oracle files shows difference.

i know the oracle temporary file is a sparse file, but the other once ?


some info :


How to Check Sparse Files with Perl

Sparse files/file holes and unexpected block size

How to deal with sparse files (ORACLE)


the tests :



$ ls -l sparse


-rw-r-----   1 root      sys 2147483679 Aug 28 08:57 sparse
$ du -k sparse
8       sparse

$ ./ sparse
blksize: 8192
sparse => size: 2147483679   actual space used: 8192


$ ls -alsh sparse
4.0K -rwxr-xr-x 1 root root  815 Aug 28 13:59
 12K -rw-r--r-- 1 root root 2.1G Aug 28 09:00 sparse

$ ./ sparse
blksize: 4096
sparse => size: 2147483726   actual space used: 12288

ls -alsh /oracle/db
total 29G
1.0K drwxr----- 3 ora102 dba   1.0K Jul 31 20:32 .
4.0K drwxr-xr-x 4 root   sys   4.0K Jul 24 13:10 ..
2.1G -rw-r----- 1 ora102 dba   2.0G Sep  5 09:05 ORCL_df02_00.dbf
2.6G -rw-r----- 1 ora102 dba   2.5G Sep  5 09:05 ORCL_df01_00.dbf
239M -rw-r----- 1 ora102 dba   1.5G Aug 29 22:14 ORCL_dftemp_00.dbf

OK:OK:OK:OK: ???????????????????????????????

./ /oracle/db/

blksize: 1024
/oracle/db/ORCL_df01_00.dbf   => size: 2682273792   actual space used: 673198592
/oracle/db/ORCL_df01_00.dbf     => size: 2145402880   actual space used: 538454528
/oracle/db/ORCL_dftemp_00.dbf => size: 1608531968   actual space used: 62437888



Valued Contributor

Re: detect sparse files

i have now the reason of "sparse files" from oracle database filesystems

the oracle database has a defined block size and oracle administrate the block management in other block size than the
file system.


Connect again the oracle database and check the oracle block size.
When you install a database, you define the oracle block size, this size is the whole store management of the database.
You can also define with new oracle rdbms releases for some tablespaces other block size ….
sqlplus ´ / as sysdba´
SQL> show parameters block_size                                                                                           
NAME                                 TYPE        VALUE     
  ------------------------------------ ----------- ------------
db_block_size                        integer     16384       
the size ist 16 KB !

So i change the blksize ( to the oracle block size) in and i get the right results.
I append it as attachment (oracle temporary files are sparse files !!)
When you check files of oracle databases , you must know the block_size of the oracle database !
The block size of the filesystem must not the block size of the files of the oracle database !