{
  "slug": "sparse-file",
  "term": "Sparse file",
  "aliases": [],
  "definition": "A file with unallocated ranges that read as zeros, allowing its logical size to exceed its allocated storage.",
  "note": "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.\n\nLinux 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.\n\nA 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.\n\nSparse 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.\n\nFor 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.",
  "status": "shipping",
  "advantages": [
    {
      "text": "Unwritten gaps can be represented without allocating data blocks for the entire logical range.",
      "citationIds": [
        "lseek",
        "inode"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Zeros returned by a read do not prove that the corresponding range is a hole.",
      "citationIds": [
        "lseek"
      ]
    },
    {
      "text": "Filesystem allocation is not a direct measurement of underlying thin-pool capacity.",
      "citationIds": [
        "inode",
        "lvmthin"
      ]
    },
    {
      "text": "Seek classification depends on filesystem behavior and can reflect page-cache state; it is not an exact allocation map.",
      "citationIds": [
        "seek-iomap",
        "seek-filemap",
        "hesela-seek-observation"
      ]
    },
    {
      "text": "The recorded dd controls concern completed operations on generated regular files; they do not establish behavior after a crash or for raw devices.",
      "citationIds": [
        "hesela-dd-evidence"
      ]
    }
  ],
  "related": [
    "e2image",
    "file-size",
    "end-of-file",
    "file-storage",
    "hole-punching",
    "file-preallocation",
    "thin-provisioning",
    "file-extent",
    "unwritten-extent",
    "filesystem-block",
    "swapfile",
    "regular-file",
    "seek-data-hole"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-15",
  "citations": [
    {
      "id": "lseek",
      "title": "Linux man-pages: lseek(2), holes and SEEK_DATA/SEEK_HOLE",
      "url": "https://www.man7.org/linux/man-pages/man2/lseek.2.html",
      "accessed": "2026-10-12"
    },
    {
      "id": "inode",
      "title": "Linux man-pages: inode(7), file size and allocated blocks",
      "url": "https://man7.org/linux/man-pages/man7/inode.7.html",
      "accessed": "2026-10-12"
    },
    {
      "id": "lvmthin",
      "title": "LVM2: lvmthin(7), physical allocation, discards and pool exhaustion",
      "url": "https://man7.org/linux/man-pages/man7/lvmthin.7.html",
      "accessed": "2026-10-12"
    },
    {
      "id": "hesela-allocation",
      "title": "Sparse files, preallocation and thin-pool capacity",
      "url": "https://hesela.com/analyses/sparse-files-preallocation-thin-capacity/",
      "accessed": "2026-10-13"
    },
    {
      "id": "hesela-observation",
      "title": "Hesela: three-run ext4 allocation observation, source hashes and environment",
      "url": "https://hesela.dev/research/allocation-observation.json",
      "accessed": "2026-10-16"
    },
    {
      "id": "seek-iomap",
      "title": "Linux v6.8 iomap seek handling of unwritten extents",
      "url": "https://github.com/torvalds/linux/blob/v6.8/fs/iomap/seek.c",
      "accessed": "2026-10-20"
    },
    {
      "id": "seek-filemap",
      "title": "Linux v6.8 page-cache seek classification",
      "url": "https://github.com/torvalds/linux/blob/v6.8/mm/filemap.c",
      "accessed": "2026-10-20"
    },
    {
      "id": "cp-implementation",
      "title": "GNU coreutils v9.4 copy.c: sparse heuristic and copy paths",
      "url": "https://github.com/coreutils/coreutils/blob/v9.4/src/copy.c",
      "accessed": "2026-10-20"
    },
    {
      "id": "hesela-seek-observation",
      "title": "Hesela: recorded sparse-copy observations and versioned method",
      "url": "https://hesela.dev/research/seek-hole-observer/README.md",
      "accessed": "2026-10-20"
    },
    {
      "id": "gnu-dd-manual",
      "title": "GNU Coreutils v9.4 manual: dd sparse and notrunc destination semantics",
      "url": "https://github.com/coreutils/coreutils/blob/9530a14420fc1a267e90d45e8a0d710c3668382d/doc/coreutils.texi",
      "accessed": "2026-10-24"
    },
    {
      "id": "hesela-dd-evidence",
      "title": "Hesela: GNU dd destination preconditions, twelve generated-file configurations and exact byte checks",
      "url": "https://hesela.dev/research/seek-hole-observer/gnu-dd/README.md",
      "accessed": "2026-10-24"
    },
    {
      "id": "dd-read",
      "title": "Linux man-pages: read(2), successful short reads and pipes",
      "url": "https://man7.org/linux/man-pages/man2/read.2.html",
      "accessed": "2026-10-24"
    }
  ],
  "provenance": [
    "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."
  ]
}
