1

Can anyone explain the core difference between HDIO_GETGEO and HDIO_GET_IDENTITY?

From the Linux documentation and this document titled: Summary of HDIO_ ioctl calls., I know that the former is for "getting device geometries" and the latter for "getting IDE identification info".

In the HDIO summary document, it is said that the object of "struct hd_geometry" is passed as an argument to a "ioctl" call and it will contain the "number of sectors".

However, HDIO_GET_IDENTITY returns an unsigned char array. But from this SO question, I hope that struct hd_driveid contains the bytes per sector and other info. And I read somewhere that hd_driveid can be passed as an argument to ioctl if HDIO_GET_IDNTITY is used in the call.

I need a clarification for all these doubts..

Also which HDIO_ ioctl call should I use to get the number of sectors and bytes per sector of my hard disk in Linux?

8
  • The numbers of tracks per cylinder, sectors per track, and bytes per sector, etc., are commonly referred to as device geometry. Jul 2, 2015 at 7:36
  • But hd_geometry does not give bytes per sector ?
    – Jackzz
    Jul 2, 2015 at 8:14
  • @Gilles - why did this get closed as off-topic?
    – slm
    Jul 2, 2015 at 12:02
  • Let us continue this discussion in chat.
    – slm
    Jul 2, 2015 at 12:36
  • 1
    GETGEO returns bios drive geometry, which is obsolete. IDENTITY returns the raw ATA device identification sector. You shouldn't use either one. Instead, simply read from the files /sys/block/sda/size and /sys/block/sda/queue/hw_sector_size. The former gives the size as a multiple of 512 bytes ( regardless of sector size of the drive ), and the latter gives the real sector size of the drive. If you want the logical sector size instead, use logical_block_size instead.
    – psusi
    Jul 2, 2015 at 12:54

1 Answer 1

1

GETGEO returns bios drive geometry, which is obsolete. IDENTITY returns the raw ATA device identification sector. You shouldn't use either one. Instead, simply read from the files /sys/block/sda/size and /sys/block/sda/queue/hw_sector_size. The former gives the size in "sectors" as if the sector size were 512 bytes, even if it isn't, and the latter gives the real sector size of the drive. If you want the logical sector size instead, use logical_block_size.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .