2

I have completely transferred a file using rsync without the use of the --sparse, -S option. I don't want to waste space and thus re-sync the file and turn it into a sparse file. Is there a way to achieve this without deleting the file on the target first? It seems the regular delta sync does not notice the fact that the file on the target system is no longer a sparse file.

I know that I can sync the file again or use dd with conv=sparse or cp with --sparse=always locally but I was wondering whether rsync can be told to reapply the sparse info.

Jotschi
  • 141

1 Answers1

4

fallocate --dig-holes {filename} can be used to create sparse holes in existing files.

See the documentation, man fallocate, which says,

-d, --dig-holes Detect and dig holes. This makes the file sparse in-place, without using extra disk space. The minimum size of the hole depends on filesystem I/O block size (usually 4096 bytes). Also, when using this option, --keep-size is implied. If no range is specified by --offset and --length, then the entire file is analyzed for holes.

Chris Davies
  • 4,560