# Module Copy-Does not handle sparse files properly

**URL:** <https://forum.ansible.com/t/module-copy-does-not-handle-sparse-files-properly/16438>\
**Category:** Ansible Project\
**Created:** [October 5, 2014, 10:52pm UTC](https://forum.ansible.com/t/module-copy-does-not-handle-sparse-files-properly/16438 "2014-10-05T22:52:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Wedaa](https://avatars.discourse-cdn.com/v4/letter/e/c0e974/32.png) [@Eric\_Wedaa](https://forum.ansible.com/u/Eric_Wedaa)\
**Post date:** [October 5, 2014, 10:52pm UTC](https://forum.ansible.com/t/module-copy-does-not-handle-sparse-files-properly/16438/1 "2014-10-05T22:52:39Z")

</div>

I just found out that Ansible does not handle Sparse Files (A file with true empty space inside it) properly with the copy module. I don’t think this is a bug, but somebody should mention this in the documentation.

> **[Sparse file](https://en.wikipedia.org/wiki/Sparse_file)**
>
> In computer science, a sparse file is a type of computer file that attempts to use file system space more efficiently when the file itself is partially empty. This is achieved by writing brief information (metadata) representing the empty blocks to the data storage media instead of the actual "empty" space which makes up the block, thus consuming less storage space. The full block is written to the media as the actual size only when the block contains "real" (non-empty) data.
> Most commonly, spar...

Code to make a sparse file

#!/usr/bin/perl

## Code Blatantly stolen from Elizabeth Zwicky

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 6, 2014, 12:30pm UTC](https://forum.ansible.com/t/module-copy-does-not-handle-sparse-files-properly/16438/2 "2014-10-06T12:30:32Z")

</div>

Yeah I don’t think we need to add specific sparse file handling to Ansible.

Ansible basically does a scp/sftp, so if those tools understand sparse files, it may be a matter of passing a flag or something, and we’d be open to patches for something like that I guess, if it were automatically detectable or reasonably safe to pass.

---

<div class="post-metadata">

**Author:** ![Eric\_Wedaa](https://avatars.discourse-cdn.com/v4/letter/e/c0e974/32.png) [@Eric\_Wedaa](https://forum.ansible.com/u/Eric_Wedaa)\
**Post date:** [October 6, 2014, 2:42pm UTC](https://forum.ansible.com/t/module-copy-does-not-handle-sparse-files-properly/16438/3 "2014-10-06T14:42:13Z")

</div>

I just think a note needs to be made in the documentation about it, and call it good.
