How to identify a block device buffer size

Bodisha

New Member
Joined
May 19, 2019
Messages
13
Reaction score
1
Credits
151
Been reading about character & block devices... and I want to figure out how to identify the /dev/sda block device buffer size in my virtual machine (RHEL). I believe this is found in the 'blockdev --report' output under the 'BSZ' field

Can someone confirm or deny this? If I'm wrong could someone point me in the right direction? Thanks
 


Confirm.
Also, for example:
Code:
blockdev --getbsz /dev/sda4
but read the man page. Kernel's idea of blocksize ( --getbsz), and physical blocksize ( --getpbsz) can be determined. Usually they co-incide in my machines.
 
Code:
blockdev --getbsz /dev/sda4
Thanks for the reply. Although I might have been unclear on what I was asking. I'm trying to figure out how to find the buffer size for the block devices in my machine

Reading through the man page, the options say

--getpbsz "Get physical block (sector) size."
--getbsz "Print blocksize in bytes"

So I'm pretty sure these options are printing the sector sizes of the drives and not the buffer size
 
Okay. The block device buffer size is one of 512, 1024, 2048, 4096 or 8192 bytes because those are the supported sizes. See:
There may be a simple command to show that buffer size for any given device, but I can't find it. Normally the kernel does it's thing with flushing buffers efficiently with robust algorithms so it's remote from userland manipulations. I think it may be possible to read the "buff" statistic in the vmstat command which outputs info on the disks with the -d option. Then you may be able to make some calculations which would indicate which of the buffer sizes is being use for any block device. The vmstat command manpage shows "buff" to be: "buff: the amount of memory used as buffers". Unfortunately I can't see this output of "buff" on my machines (debians) because the vmstat command appears not to have been configured in the compilation to use it.
 
There may be a simple command to show that buffer size for any given device, but I can't find it.
hdparm -I /dev/sdx

Does it for "some" devices, not all.
Typically it works for "most" SSDs, but not NVME M.2 drives.
So far it has always worked for me on old spindle/disk type SATA drives.
 
Thanks for that one dos2unix. Your command holds the best promise.
Unfortunately for this machine I'm on at the moment with 2 HDDs, the result isn't forthcoming, but the variables exist in hdparm so there is some intention to gather the information. The following output is on an installation of debian testing upgraded to current:
Code:
[root@owl ~]# hdparm -I /dev/sda | grep -i buffer
        cache/buffer size  = unknown

[root@owl ~]# hdparm -I /dev/sdb | grep -i buffer
        cache/buffer size  = unknown
Perhaps the OP will have more luck.
Edit: I've just tried another hardware viewing program, also without the sought output:
Code:
[root@owl ~]# smartctl -x /dev/sdb | grep -i -e buffer -e cache
Write cache is:   Enabled
Wt Cache Reorder: Enabled
 
Last edited by a moderator:

Members online


Top