Austin Donnelly wrote:
[...]Yes, try it with dd and cp (GNU version only?):
dd if=/dev/zero of=/tmp/zero-test count=1000 cp --sparse=always /tmp/zero-test /tmp/zero-sparse ls -l /tmp/zero-test /tmp/zero-sparse du -cs /tmp/zero-test /tmp/zero-sparse
What I do not know is how many fs support it, and if they can do on
the fly or a forced copy is needed
It is the copy which makes the sparse file. You can't make a hole in a file merely by writing a bunch of zeros to it. You can only do it by seeking past the (current) end of the file, then writing non-zero data. The bytes you seeked over are the hole, and will be read as if zeros.
GNU cp uses a bunch of heuristics to discover runs of zeros in the input file and seek over them in the output file, rather than just writing zeros.
Austin
I looked up heuristic it said it meant heuristisch! How can this be so?
I thought when i cp'd something i was totally making a copy of the file and simply giving it a new name. The size never changes, so how could this be true?
carol