concept Data & storage
Sparse files: logical size versus allocated blocks
A sparse file’s holes read as zeros without requiring data blocks. A copy that stores those zeros in allocated blocks can use more disk space than the original while keeping the same bytes and logical length.
What it means
A hole is a range of a sparse file that reads as zeros. It counts toward the file’s logical length even when no data blocks are allocated for that range. Microsoft’s sparse file documentation describes this distinction. If a copy writes those zeros into allocated blocks instead of preserving the hole, the copy can use more space without getting any longer.
Try it
Start with D H H H H H H H H D as the Logical extent map and 4 KiB as the Extent size. Each position represents one fixed-size range: D declares allocated data and H declares a hole. It uses synthetic inputs, not a measurement of your disk.
Sparse files: logical size versus allocated blocks
Inspect holes and allocated extents in a synthetic file; compare a hole-preserving copy with an explicitly materializing copy and calculate both sizes.
Synthetic inputs only. This is not a measurement of your hardware or service.
Declared holes contribute to logical length but not data-block allocation. A materializing copy allocates those regions too.
Logical length versus allocated data blocks
- Logical length
- 40 KiB
- Source data allocation
- 8 KiB
- Copy data allocation
- 8 KiB
| Extent | D=data, H=hole | Allocated in source | Allocated in copy |
|---|---|---|---|
| 0 | D | Yes | Yes |
| 1 | H | No | No |
| 2 | H | No | No |
| 3 | H | No | No |
| 4 | H | No | No |
| 5 | H | No | No |
| 6 | H | No | No |
| 7 | H | No | No |
| 8 | H | No | No |
| 9 | D | Yes | Yes |
Evaluated evidence
- Logical extent map
- D · H · H · H · H · H · H · H · H · D
- Extent size (KiB)
- 4
- Copy behavior
- preserve
Holes are supplied as H, not inferred from zero content. Metadata, compression, reflinks and actual filesystem behavior are excluded.
About this model
Every input is local synthetic evidence. Numbers stay as raw text until this model validates them. The shown evaluated values come from the same result as the explanation.
Presets replace the entire scenario. Reset restores all starting fields, scenario selection and model state; it does not change the open or closed state of this help or article FAQ.
No external request, device command, stored-input history or measurement is performed.
- Count the source blocks. All ten positions count toward logical length: 10 × 4 KiB = 40 KiB. Only positions 0 and 9 are
D, so source data allocation is 2 × 4 KiB = 8 KiB. - Compare the copies. With Copy behavior set to Preserve holes, positions 1 through 8 remain holes, so the copy also allocates 8 KiB. Change only that control to Materialize holes as allocated blocks. Those eight ranges now account for another 32 KiB of data blocks in the copy, bringing its allocation to 40 KiB. The source stays at 8 KiB of allocation, and both files have the same 40 KiB logical length.
- Leave the behavior unknown. With Unknown / evidence unavailable, you can still calculate the source figures from the map, but the copy’s allocation is not established. Unknown does not mean zero.
To change the example, enter 1 to 64 D or H tokens separated by single spaces. Enter the extent size as whole-number decimal text from 1 through 1024, in KiB. An empty map, an entry such as D X, or a size such as 4.0 is invalid; it does not produce a size estimate. Reset restores the default map, 4 KiB extent size and hole-preserving behavior. It also returns the scenario, step and virtual time to their starting values and clears errors, history and any comparison.
In practice
Zero bytes are not proof of a hole. An allocated range filled with zeros and a hole can return the same bytes on a read. Sparse file behavior distinguishes how the range is stored from what it contains. For example, at 4 KiB per position, D D allocates 8 KiB in the model even if both ranges contain only zeros; H H allocates no data blocks. Both maps describe 8 KiB of logical length. The map declares the holes; the model does not infer them from content.
For a real copy, check the exact tool and options, how the source filesystem reports holes, and whether the destination filesystem can preserve them. On Linux, SEEK_DATA and SEEK_HOLE can help a copier identify ranges to copy or leave as holes, but they do not guarantee a map of every physically allocated block. Linux lseek documentation
The example counts data blocks only; it omits metadata, compression and reflink sharing. Use logical length to answer how many bytes the file presents, not how much space to budget for its copy. Until you know how the copy handles holes, matching logical bytes do not establish matching allocation.
Frequently asked questions
Editorial questions based on the listed sources and explicitly labeled local examples.
Are zero-filled data and holes identical?
They can read as zeros while having different allocation. A hole is represented without storing the corresponding full data extent; explicitly stored zero bytes need not have the same physical allocation.
Why can copying use more space?
The materializing copy mode allocates every logical extent, including holes. The hole-preserving mode retains the sparse representation. Both can expose the same logical bytes but consume different space.
Is allocated size the logical length?
No. The default file has ten 4 KiB logical extents but only two allocated data extents: 40 KiB logical length and 8 KiB modeled allocation. Metadata and real allocation granularity are excluded.
Does every copy tool preserve holes?
This example establishes no universal tool behavior. Its copy mode is an explicit premise; check the exact tool, options and source/destination filesystem before expecting real hole preservation.
Sources & model boundaries
Primary references used for this explanation. The interactive example is an educational model, not a live check.
- Sparse files
Sparse allocation behavior. Sparse representation separates logical byte ranges from physically allocated storage, with holes supplying zeros on reads.
Checked .
- Linux man-pages: lseek(2)
Seeking file data and holes. Hole-aware copying can preserve sparse allocation, but SEEK_HOLE/DATA are not a guaranteed map of every physically allocated block.
Checked .