6

I have a Seagate 750GB drive.

Parted shows the drive as 750GB

parted /dev/sdc print
Model: ST375064 0AS (scsi)
Disk /dev/sdc: 750GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size   File system  Name     Flags
 1      17.4kB  750GB  750GB  ext3         primary

However, the size entry in /proc/partitions is supposedly in blocks:

cat /proc/partitions
major minor  #blocks  name
8       32  732574584 sdc

Parted says the block size is 512B, blockdev --getbsz /dev/sdc says the block size is 4096.

But... it is clear that /proc/partition is wrongly reporting the device size in KiB rather than blocks.

Can this behavior be depended on across Linux and/or kernel versions? (I need a scriptable and consistent way of finding the size of a block device)

Centos 6.6 with 3.10 kernel.

EDIT I

lsblk -o kname,phy-sec,log-sec,min-io
KNAME PHY-SEC LOG-SEC MIN-IO
sda       512     512    512
sda1      512     512    512
sda2      512     512    512
Danny
  • 255

2 Answers2

1

parted and lsblk reports the logical/physical block (aka sector) size properly. You can double check this using smartctl -i /dev/sda.

blockdev --getpbsz --getss /dev/sda reports the right information too.

/proc/partitions reports sizes in KiB but it's completely unrelated to the physical block size of the device, instead it's the buffer cache block size.

blockdev --getbsz /dev/sda probably reports the actual IO size ( 4KiB matches kernel page size).

wazoox
  • 7,156
-2

Use /proc/partitions or (c)fdisk. Something that doesn't pretty-print results to be better human-readable.

The blocks in /proc/partitions are always in 512B blocks... newer disks will use 4k blocks internally, but usually emulate 512B blocks to the outside. Some disks will only speak 4k blocks, also on the outside, but /proc/partitions will still print results in 512B blocks.

Sig-IO
  • 1,076
  • 9
  • 11