How to get HFS+ filesystem blocksize

Solution 1:

You could try "stat" with the "%k" format option. According to the man page this is the "Optimal file system I/O operation block size". Command line is:

stat -f "%k" FILE

Where "FILE" is any regular file on your system (e.g. "~/.profile"). It should say "4096" or something like that. I cannot 100% guarantee this is what you're looking for, but it seems close.

Solution 2:

If you want to verify the block size, you can modify the answer given by neuroburn to include the file size and the number of 512-byte blocks allocated:

stat -f "%k, %z, %b" FILE

The number of allocated 512-byte blocks will be a multiple of the number of 512-byte blocks in one file system block. For example, a 4096-byte file system block contains 8 512-byte blocks:

MacBook-Pro:~ ian$ echo foo > foo.txt
MacBook-Pro:~ ian$ ls -l foo.txt
-rw-r--r--  1 ian  staff  4 12 Jul 00:21 foo.txt
MacBook-Pro:~ ian$ stat -f "%k, %z, %b" foo.txt
4096, 4, 8

Doing this a few times will give more confidence in the simpler command proposed by neuroburn. (Please note this answer has been edited to correct the command parameters… former parameters "%k, %z, %” caused the command to fail.)