understanding sparse files

Fbsd8 fbsd8 at a1poweruser.com
Wed Jan 16 21:21:23 UTC 2013


I want to understand what is going on inside of sparse files.

I have a test case set up.

I have a small directory tree set up containing just the systems running 
libraries. The directory tree contains a copy of the following systems 
directories, /bin. /lib, /libexec, /sbin, and /usr which has a combined 
size of 195M. This directory tree is what gets copied into the sparse 
files I create.

Now I create a sparse file with a allocated file size of 300M and copy 
that 195M directory tree into it.
ls -lh shows 300M as the allocation size
du -h  shows 270M as the occupied size

I would expect the occupied size to be 195M, the size of the source 
loaded into that sparse file.


Now I reran the same test again changing only the allocation size to 1G.
ls -lh shows 1G as the allocation size
du -h  shows 463M as the occupied size

So my question is, why does the occupied size not match the real size of 
the data content in the sparse file?

Also why as the allocated space increases does the occupied size increase?




More information about the freebsd-questions mailing list