How can I find out the HFS+ filesystem blocksize for a local volume on a MacbookPro5,4. I think its 4k. I need to confirm this. Diskutil reports that the disk blocksize is 512 bytes.
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.
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.)
That's a fair enough measurement, but the right way to do it would be to query the filesystem itself, which you can do programmatically by statfs(). Alternatively, you can read directly from the HFS volume header - a free tool called HFSleuth, at http://www.newosxbook.com/ - allows you to do just that.