10

With stat 8.13 on a Debian based Linux - among many others - the following FORMAT directives (--format=) are offered:

In combination with --file-system (-f):

  • %s Block size (for faster transfers)
  • %S Fundamental block size (for block counts)

Question(s): What exactly is meant?

My best guess is that %s, %S equals %b (display in Blocks) and %B (display block's size), where the latter are for files and the first two are for file systems. Is that correct?

2
  • Consider making the part about %s and %S a separate question, since the question don_crissti linked to seems to answer the first of your two questions perfectly.
    – Mikel
    Jun 5, 2015 at 19:59
  • If you'd searched for "stat" questions, you'd already have an answer for your question about %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.
    – Mikel
    Jun 6, 2015 at 0:37

1 Answer 1

5
   %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 */
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .