%S fundamental block size (for block counts)
tells you how big each block is on the file system. On most file systems, this is the smallest amount of space any file can take up. Each file uses a multiple of this.
For example,
$ echo > a # create a file containing a single byte
$ du -h a # see how much disk space it's using
4.0K a
$ stat -f -c '%S' . # see what stat thinks the block size is
4096
$ tune2fs -l /dev/mydrive | grep '^Block size'
4096
I'm not 100% sure it always works like this. For example, I expect it could also decide to print 512
or 1024
, even if the underlying block size is different, provided stat -c %b FILE
* stat -f -c %S FILE
= du --block-size=1 FILE
. The exact implementation would depend on the file system.
%s block size (for faster transfers)
suggests how many bytes you should read at a time if you're copying large files, for example what you should use as the bs
(blocksize) parameter when using dd
. But on the systems I checked, it always prints 4096
, even where larger values might be faster. See Is there a way to determine the optimal value for the bs parameter to dd? for more discussion of that.
Technically, this information (and all the information from stat -f
) comes from the statvfs
system call.
%s
corresponds to the f_bsize
field, and %S
is f_frsize
.
So you could look into their precise meanings starting with the statvfs man page
unsigned long f_bsize; /* Filesystem block size */
unsigned long f_frsize; /* Fragment size */
%s
and%S
a separate question, since the question don_crissti linked to seems to answer the first of your two questions perfectly.%f
. Thanks for narrowing the scope to%s
and%S
. That makes the question more useful and easier to search. I've retracted my close as duplicate vote.