Explain and/or demonstrate and/or point to documenation on the subject of ext3 & sparse deltas

Explain and/or demonstrate and/or point to documenation on the subject of ext3 & sparse deltas.
jerry_corneliusAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wrrrxCommented:
term 'sparse files'  reffers to files that have sequences of null bytes.  Filesystems such as ext3 can recognize those files and write them in compact (sparse) mode.  Linux `cp' command has '--sparse' option explained in the man page.

So,
# create a sparse file full of zeros
$time dd if=/dev/zero bs=1024 count=$[1024*256] | cp --sparse=always /dev/stdin 256Meg.file.sparse
262144+0 records in
262144+0 records out

real    0m17.178s
user    0m2.417s
sys     0m21.810s

# create a non-sparse file full of zeros
$time dd if=/dev/zero bs=1024 count=$[1024*256] | cp --sparse=never /dev/stdin 256Meg.file.full
262144+0 records in
262144+0 records out

real    0m25.773s
user    0m1.089s
sys     0m24.785s

#copy sparse file and note time
$time cp 256Meg.file.sparse 256Meg.file.sparse2

real    0m6.832s
user    0m0.967s
sys     0m5.680s

# copy file in full
$time cp --sparse=never 256Meg.file.full 256Meg.file.full2

real    0m58.370s
user    0m0.268s
sys     0m14.488s

## note the differece: In the 1st case we have almost no disk usage as sys.time is about the same  
##  as real.time.   In the 2nd case we have disk usage.  
## PS: tests done on a kinda slow-old machine, it shoudn't take 1min to copy 256Meg

# check sizes of files
$ls -alh 256*
-rw-------    1 konstantin konstantin     256M Mar 24 17:33 256Meg.file.full
-rw-------    1 konstantin konstantin     256M Mar 24 17:35 256Meg.file.full2
-rw-------    1 konstantin konstantin     256M Mar 24 17:32 256Meg.file.sparse
-rw-------    1 konstantin konstantin     256M Mar 24 17:34 256Meg.file.sparse2

# check disk space that is actually used
$du -h 256*
257M    256Meg.file.full
257M    256Meg.file.full2
0       256Meg.file.sparse
0       256Meg.file.sparse2


Let me know if you have questions

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.