sparse-file · shipping

Sparse file

A file with unallocated ranges that read as zeros, allowing its logical size to exceed its allocated storage.

On Linux, seeking past EOF alone does not extend a file; writing there leaves a zero-reading gap. SEEK_DATA and SEEK_HOLE are not exact physical allocation maps because filesystems may conservatively report every offset as data.

Linux st_blocks counts 512-byte units; st_blksize is a preferred I/O size, not that count's unit. A three-file Hesela observation on ext4 found identical zero readback before and after allocation changes; this is a scoped example, not a universal physical-space measurement.

A SEEK_HOLE result can include allocated unwritten ranges. In Hesela's ext4 observation, a source preread changed GNU cp's destination allocation for a half-preallocated zero file without changing any bytes; fully preallocated files were a negative control. A sparse copy is not a guarantee of preserving preallocation.

Sparse output also needs a content precondition when updating an existing destination. GNU dd with conv=sparse,notrunc can seek past nonzero bytes instead of replacing them with input zeros; this is documented behavior, not hole punching. In a controlled GNU dd 9.4 example, 8192 of 16384 intended replacement bytes remained stale even after a successful final fsync. Larger blocks hid the mismatch for a mixed input but not for an all-zero control. Check exact contents and required surrounding data separately from allocation or synchronization. Operational inference: exclude concurrent writers so skipped ranges remain zero throughout the update.

For GNU dd with bs= and no data-transforming conversion, a short input read can reach the sparse-output check before the requested block is full. iflag=fullblock accumulates reads but does not establish zero destination contents. This source-based pipe-input caveat was not exercised by the regular-file experiment.

Relations

related
File size, End of file, File storage, Hole punching, File preallocation, Thin provisioning, File extent, Unwritten extent, Filesystem block, Swapfile, Regular file, SEEK_DATA / SEEK_HOLE

Advantages

  • Unwritten gaps can be represented without allocating data blocks for the entire logical range. [1, 2]

Limitations

  • Zeros returned by a read do not prove that the corresponding range is a hole. [1]
  • Filesystem allocation is not a direct measurement of underlying thin-pool capacity. [2, 3]
  • Seek classification depends on filesystem behavior and can reflect page-cache state; it is not an exact allocation map. [6, 7, 9]
  • The recorded dd controls concern completed operations on generated regular files; they do not establish behavior after a crash or for raw devices. [11]

Citations

  1. Linux man-pages: lseek(2), holes and SEEK_DATA/SEEK_HOLE (accessed 2026-10-12)
  2. Linux man-pages: inode(7), file size and allocated blocks (accessed 2026-10-12)
  3. LVM2: lvmthin(7), physical allocation, discards and pool exhaustion (accessed 2026-10-12)
  4. Linux v6.8 iomap seek handling of unwritten extents (accessed 2026-10-20)
  5. Linux v6.8 page-cache seek classification (accessed 2026-10-20)
  6. Hesela: recorded sparse-copy observations and versioned method (accessed 2026-10-20)
  7. Hesela: GNU dd destination preconditions, twelve generated-file configurations and exact byte checks (accessed 2026-10-24)

Further reading

  1. Sparse files, preallocation and thin-pool capacity (accessed 2026-10-13)
  2. Hesela: three-run ext4 allocation observation, source hashes and environment (accessed 2026-10-16)
  3. GNU coreutils v9.4 copy.c: sparse heuristic and copy paths (accessed 2026-10-20)
  4. GNU Coreutils v9.4 manual: dd sparse and notrunc destination semantics (accessed 2026-10-24)
  5. Linux man-pages: read(2), successful short reads and pipes (accessed 2026-10-24)
Sources & caveats
  • The concurrency precondition is an operational inference; no concurrency experiment was performed.
  • Sparse-copy supplement: one host, Linux 6.8.0-146-generic, ext4/tmpfs and GNU cp 9.4-3ubuntu6.3. This is a file-level observation, not a crash, capacity-exhaustion or device-traffic test.
  • GNU dd supplement: 12 selected regular-file configurations, repeated on one Ubuntu host with GNU dd 9.4-3ubuntu6.3. Not a failure-rate sample, crash test, device overwrite, sanitization test or independent-host replication.

JSON: /data/terms/sparse-file.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. Sparse file. Hesela. 2026-11-15. https://hesela.dev/terms/sparse-file/