设备的扇区大小不存储在 MBR 中。
用户空间命令,例如fdisk使用BLKBSZGET和BLKSSZGET ioctls 从磁盘检索扇区大小。这些ioctls 由内核中的驱动程序处理,它从驱动器本身检索相关信息。
(相关ioctl的文档不多,你需要查看内核源代码。)
您可以使用其他直接查询驱动器的工具查看相关信息,例如hdparm。在小型 SSD 上,hdparm -I告诉我
[...]
Logical Sector size: 512 bytes
Physical Sector size: 512 bytes
Logical Sector-0 offset: 0 bytes
[...]
cache/buffer size = unknown
Form Factor: 2.5 inch
Nominal Media Rotation Rate: Solid State Device
[...]
Run Code Online (Sandbox Code Playgroud)
在具有 4K 扇区的大型旋转磁盘上,我得到了
[...]
Logical Sector size: 512 bytes
Physical Sector size: 4096 bytes
Logical Sector-0 offset: 0 bytes
[...]
cache/buffer size = unknown
Form Factor: 3.5 inch
Nominal Media Rotation Rate: 5400
[...]
Run Code Online (Sandbox Code Playgroud)