Description of problem: “blockdev –-getbsz” forever return 4096. Version-Release number of selected component (if applicable): All. How reproducible: Run: smartctl -i /dev/sda; blockdev --getbsz --getpbsz /dev/sda Steps to Reproduce: smartctl --getbsz /dev/sda Actual results: 4096 Expected results: 512 Additional info: This utility get me the strange results (output reduced): smartctl -i /dev/sda; blockdev --getbsz --getpbsz /dev/sda Device Model: INTEL SSDSC2KB480G8 User Capacity: 480,103,981,056 bytes [480 GB] Sector Sizes: 512 bytes logical, 4096 bytes physical Rotation Rate: Solid State Device 4096 4096 smartctl -i /dev/sdb; blockdev --getbsz --getpbsz /dev/sdb Device Model: HGST HUS722T2TALA604 User Capacity: 2,000,398,934,016 bytes [2.00 TB] Sector Size: 512 bytes logical/physical Rotation Rate: 7200 rpm Form Factor: 3.5 inches 4096 512 As you can see “-–getbsz” forever 4096. But I think it must be forever 512. Thank you. Ilia.
Linux kernel provides three basic ioctls: case BLKBSZGET: /* get block device soft block size (cf. BLKSSZGET) */ return put_int(arg, block_size(bdev)); case BLKSSZGET: /* get block device logical block size */ return put_int(arg, bdev_logical_block_size(bdev)); case BLKPBSZGET: /* get block device physical block size */ --getbsz means BLKBSZGET. This size does not describes the device from "topology" point of view (like logical or physical sector), but it's block used internally by kernel for the device. It's for example on the fly modified by filesystem. See "mkfs.ext4 -b <size>" (default is 4KiB). You can also change from userspace by --setbsz (but the setting is valid only for the open descriptor). I'll add more information to the upstream blockdev.8 man page to make it more obvios. So, not a bug. Although at first glance it seems strange :-)
Example: # mkfs.ext4 -b $((2 * 1024)) /dev/sdc # blockdev --getbsz /dev/sdc 4096 # mount /dev/sdc /mnt/test # blockdev --getbsz /dev/sdc 2048 # umount /mnt/test # blockdev --getbsz /dev/sdc 4096 Note that the default is usually 4096 due to system PAGE_SIZE.
Oh. Maybe you can add new parameter for more obvious. --getlbsz - Get logical block (sector) size. Physical disk. See BLKSSZGET analog of: --getpbsz - Get physical block (sector) size. Physical disk. See BLKPBSZGET --getbsz - Print blocksize in bytes. Used inside kernel. See BLKBSZGET Or something similar. Thank you.