Quote:
Originally Posted by edenCC
Hi, List;
Is there any simple ways for me to find out these files that have "holes" in them?
Code:
[admin@admon ~]$ls -sh /data/00/091/_3FFA3951AE8D
40K /data/00/091/_3FFA3951AE8D
[admin@admon ~]$ll /data/00/091/_3FFA3951AE8D
-rw-r--r-- 1 coremail coremail 805366246 Apr 15 2005 /data/00/091/_3FFA3951AE8D
I also found a issue that,when using rsync(version 2.6.3) to copy these files to another server, they would take exact 805366246 bytes size, no 40KB.
|
Files with holes in them are called sparse files and are described in
http://administratosphere.wordpress....t-why-and-how/. So basically, to detect the sparseness of a file, compare the size of the number of blocks allocated to the reported size of the file. If blocks * block_size is bigger than the reported size, you've got sparseness.
Unfortunately, there don't seem to be good tools to detect and deal with these files in general. I can use 'stat -c "%s -(%b * %B)" FILENAME |bc' to detect sparse files. For a typical non-sparse file, this gives me a negative number, since the size isn't an exact multiple of the block size. However, for a sparse file, it gives me a positive number which is the number of bytes in holes, which are not taking up any disk space.
Rsync can detect and create holes in files, but you have to give it the "--sparse" option.