Linux supports sparse files aka 'file with holes'
Note following commands
alias mystat='stat -c "%n: %B*%b blocks %s bytes"'
dd if=/dev/zero bs=1024k seek=4096 count=0 of=file-with-holes
ls -l file-with-holes
-rw-r--r-- 1 root root 4294967296 Feb 25 18:33 file-with-holes
mystat file-with-holes
file-with-holes: 512*0 blocks 4294967296 bytes
cp file-with-holes other-file
mystat other-file
other-file: 512*0 blocks 4294967296 bytes
cat file-with-holes > file-without-holes
mystat file-without-holes
file-without-holes: 512*8388608 blocks 4294967296 bytes
The cat command removed all holes from the file.
Is there a way to get the holes back?
bsdtar -S
- this will create sparse files on extraction (unlike GNU tar). Not really the answer for a full fs, but maybe good if restoring a backup. Also seecpio --sparse
. – Graeme Feb 25 '14 at 18:21-S
forrsync
. I already saved a nuber of hundreds gigs. – Feb 25 '14 at 19:14