3

I need to find out what the kernel block size is from vmstat output. I am specifically looking for kernel block size as defined in Block devices and block sizes. There it says all Linux blocks are currently 1024 bytes, but this is not true for old kernels.

Is there a command I can use to view the kernel block size?

3
  • 1
    Why? What are you trying to do?
    – ewwhite
    Oct 18 '12 at 0:55
  • I am trying to read the vmstat output in a meaningful way. Right now I can see blocks in and blocks out, but that does not tell me how much that is in terms of size. I would like to know if 512 B = 1 block or 1KB = 1 block, or something else.
    – dabest1
    Nov 2 '12 at 17:36
  • 1
    Linux uses 4KiB blocks almost universally.
    – vonbrand
    Jan 24 '13 at 19:17
3

man 8 vmstat says:

NOTES

    All linux blocks are currently 1024 bytes.

From sysstat/common.c

        /* One can also use getpagesize() to get the size of a page */
        if ((size = sysconf(_SC_PAGESIZE)) == -1) {
                perror("sysconf");
        }

From unistd.h

./unistd.h-/* Return the number of bytes in a page.  This is the system's page size,
./unistd.h-   which is not necessarily the same as the hardware page size.  */
./unistd.h:extern int getpagesize (void)  __THROW __attribute__ ((__const__));
3
  • As I mentioned in my question, I think this applies to current versions of Linux only, but does not apply to older kernels. Thus I am asking if there is a command or configuration which will show the actual block size.
    – dabest1
    Jan 30 '14 at 23:16
  • Don't be afraid to look at the code.
    – user55518
    Jan 30 '14 at 23:50
  • The number of blocks read according to vmstat for copying a 17GiB file to /dev/null (restarting the machine each time to avoid cache hits) is way too low for any of the block sizes discussed here and varies between repeated runs more than can be explained by I/O from system processes. Jun 18 '20 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.