Sparse files
A file is a sequence of indexed blocks. Blocks are mapped from the i-node to the logical offset of the file they represent.
A file that has one or more indexes that are not mapped to a data block is referred to as being sparsely-allocated or a sparse file. A sparse file will have a size associated with it, but it will not have all of the data blocks allocated to fulfill the size requirements. To identify if a file is sparsely-allocated, use the fileplace command. It will indicate all blocks in the file that are not currently allocated.
A sparse file is created when an application extends a file by seeking to a location outside the currently allocated indexes, but the data that is written does not occupy all of the newly assigned indexes. The new file size reflects the farthest write into the file.
A read to a section of a file that has unallocated data blocks results in a buffer of zeroes being returned. A write to a section of a file that has unallocated data blocks causes the necessary data blocks to be allocated and the data written.
This behavior can affect file manipulation or archival commands. For example, the following commands do not preserve the sparse allocation of a file:
The result of a file being copied or restored from the preceding commands has each data block allocated, and thus have no sparse characteristics. However, the following archival commands either preserve sparse characteristics or actively sparse a file:
Because it is possible to overcommit the resources of a file system with sparse files, care should be taken in the use and maintenance of files of this type.