Interview Prep/Linux/Filesystem Hierarchy, Inodes & Links

What is a sparse file?

AdvancedConceptFilesystem Hierarchy, Inodes & Links
Answer

A sparse file has holes: ranges never written that occupy no disk blocks and read as zeros. VM disk images and database files are often sparse, so ls -l (apparent size) is much larger than du (allocated blocks).

truncate -s 10G disk.img
ls -lh disk.img; du -h disk.img
cp --sparse=always src dst
rsync -S src dst

Copying without sparse awareness can fill a disk unexpectedly.

All Linux questions Roadmap: Linux

More on Filesystem Hierarchy, Inodes & Links