{{Header}}
{{title|title=
Sparse files
}}
{{#seo:
|description=On Sparse Files, checking their real size versus their apparent size.
|image=Backgrounds-164099640.jpg
}}
[[File:Backgrounds-164099640.jpg|thumb]]
{{intro|
On sparse files, checking their real size versus their apparent size.
}}
= Introduction =
{{project_name_long}} KVM images are sparse files. As a result, on common Linux distributions and file systems such as ext4, these may appear to take 100 GB of disk space, but in reality use only ~1 GB of disk space at the time of writing. Different utilities show the apparent size versus the actual size.
Wikipedia notes:
https://en.wikipedia.org/wiki/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 disk instead of the actual "empty" space which makes up the block, using less disk space. The full block size is written to disk as the actual size only when the block contains "real" (non-empty) data. 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.= Check Real Size = You must change into the correct directory first, depending on which location you want to check. For your home folder: {{CodeSelect|code= cd ~ }} Or: {{CodeSelect|code= cd /var/lib/libvirt/images/ }} Run: {{CodeSelect|code= du -h {{project_name_gateway_short}}-*.qcow2 }} This should show something like:
2.5G {{project_name_gateway_short}}-*.qcow2
= Check Apparent Size =
Run:
{{CodeSelect|code=
du -h --apparent-size {{project_name_gateway_short}}-*.qcow2
}}
This should show something like:
101G {{project_name_gateway_short}}-*.qcow2
= Also See =
Maybe of interest:
* [https://libguestfs.org/virt-sparsify.1.html virt-sparsify] (available in Debian in the package [https://packages.debian.org/{{Stable project version based on Debian codename}}/libguestfs-tools libguestfs-tools])
= Footnotes =
{{reflist|close=1}}
[[Category:Documentation]]
{{Footer}}