encyclopegia.org

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, sparse files are created when blocks of the file are never written to. This is typical for random-access files like databases. Some operating systems or utilities go further by "sparsifying" files when writing or copying them: if a block contains only null bytes, it is not written to storage but rather marked as empty. When reading sparse files, the file system transparently converts metadata representing empty blocks into "real" blocks filled with null bytes at runtime. The application is unaware of this conversion. Most modern file systems support sparse files, including most Unix variants and NTFS. Apple's HFS+ does not provide support for sparse files, but in OS X, the virtual file system layer supports storing them in any supported file system, including HFS+. Apple File System (APFS) also supports them.…

.]] 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, sparse files are created when blocks of the file are never written to. This is typical for random-access files like databases. Some operating systems or utilities go further by "sparsifying" files when writing or copying them: if a block contains only null bytes, it is not written to storage but rather marked as empty. When reading sparse files, the file system transparently converts metadata representing empty blocks into "real" blocks filled with null bytes at runtime. The application is unaware of this conversion. Most modern file systems support sparse files, including most Unix variants and NTFS. Apple's HFS+ does not provide support for sparse files, but in OS X, the virtual file system layer supports storing them in any supported file system, including HFS+. Apple File System (APFS) also supports them. Sparse files are commonly used for disk images, database snapshots, log files and in scientific applications. dd of=sparse-file bs=5M seek=1 count=0 will create a file of five mebibytes in size, but with no data stored on the media (only metadata). (GNU dd has this behavior because it calls ftruncate to set the file size; other implementations may merely create an empty file.) Similarly the truncate command may be used, if available: truncate -s 5M On Linux, an existing file can be converted to sparse by: fallocate -d There is no portable system call to punch holes; Linux provides fallocate(FALLOC_FL_PUNCH_HOLE) , and Solaris provides fcntl(F_FREESP) . ls -ls sparse-file Alternatively, the du command prints the occupied space, while ls prints the apparent size. In some non-standard versions of du , the option prints the occupied space in bytes instead of blocks, so that it can be compared to the ls output: du --block-size=1 sparse-file ls -l sparse-file Note the above du usage has the abbreviated option syntax format "du -B 1 sf", itself equivalent to the shortest version "du -b sf" as stated in the du manual: is equivalent to . Also, the tool filefrag from e2fsprogs package can be used to show block allocation details of the file. filefrag -v sparse-file cp --sparse=always file1 file1_sparsed Some cp implementations, like FreeBSD's cp, do not support the --sparse option and will always expand sparse files. A partially viable alternative on those systems is to use rsync with its own --sparse option instead of cp. Unfortunately, older versions of rsync do not support --sparse combined with --inplace . Via standard input, sparse file copying is achieved as follows: cp --sparse=always /dev/fd/0 new-sparse-file Creating sparse files in Windows Server using fsutil Creating sparse files in Solaris using mkfile(1M) View the Size of the Sparse File of a Database Snapshot SEEK_HOLE or FIEMAP: Detecting holes in sparse files virtsync is a commercial solution to rsync's --sparse and --inplace issue. SparseChecker – Utility that allows to manage the sparse files on NTFS file system Phantom – a program to convert files to sparse files to reduce storage consumption ArchLinux Wiki: Sparse file

References

No reference rows published for this article.

Cite this article

MLA

"Sparse file." encyclopegia.org, 2026, https://encyclopegia.org/wiki/sparse-file. Accessed 24 November 2026.

Chicago

"Sparse file." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/sparse-file.

APA

encyclopegia.org. (2026). Sparse file. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/sparse-file

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

File Allocation Table

stub · references available

binary file

stub · references available

System File Checker

stub · references available

Drug Master File

stub · references available

Unix file permissions

stub · references available

hidden file system object

stub · references available

module file

stub · references available

Common Object File Format

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1374022383 · 0.5 · snapshot enwiki-001374022383

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.