The other day I tried figuring out how much disk space a small file
took. I used stat, but I only realized today that stat does not provide
that information directly, as explained by Eric Blake and Pádraig Brady
in http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10561
This information is provided indirectly by %b and %B. Multiplying the 2
should give the size on disk. Example:
stat -c 'allocated-space=%B*%b apparent-size=%s' $file
Currently, this information can be obtained from du:
$ stat -c '%s' /etc/phpmyadmin/htpasswd.setup
54
chealer@vinci:~$ du -h /etc/phpmyadmin/htpasswd.setup
4,0K /etc/phpmyadmin/htpasswd.setup
chealer@vinci:~$
However, it would be quite useful if stat could be used to display
simultaneously a file's real size and size on disk.
Eric Blake suggested this directive to be %S. For the description, he
suggested:
%S Allocated size (same as %b * %B)
I would like to aim for clarity, as these various statistics can be
confusing. I suggest to use the name "Size on disk". I also suggested
the following:
Size occupied when including slack space
Size of the clusters occupied
I suggest the following synthesis:
Allocated size (space allocated on the storage device, same as %b * %B).
This is the size of the allocated clusters, which includes slack space.