IDE drive detection under libata

Alan Cox alan at redhat.com
Tue May 22 23:37:09 UTC 2007


On Tue, May 22, 2007 at 05:17:46PM -0600, Charles Curley wrote:
> * At backup time, is there any way to detect whether a drive that
>   appears as /dev/sdX is an IDE drive?

You can issue ioctls to it and see what happens. Various IDE specific
ioctls are supported such as HDIO_GET_IDENTITY which you will want later

> * At backup time, is there any way to find out which /dev/hdX drive it
>   would be so I can mung the restoration scripts approriately.

It doesn't work like that. There is no guarantee a given ATA drive that
is visible via the new drivers is even accessible via the old ones or that
it isn't magically munged

(eg libata drivers with JMicron gives you AHCI and PATA split typically as
	first scsi disk -> SATA channel 0
	second scsi disk -> SATA channel 1
	third scsi disk -> PATA channel 0

what you get in compatibility mode depends on the BIOS settings and can vary
even including things like
	primary master -> SATA chan 0
	primary slave -> SATA chan 1
	secondary -> PATA

)

> * I found several comments on this list and elsewhere that indicate
>   that /dev/hda will map to /dev/sda. Is this always true?

No.

Historically IDE happened to guarantee that hda/hdb mapped to the first
controller channel in legacy mode and hdc/hdd to the second (no other
ordering is guaranteed). libata supports hotplug of controllers and devices
so no ordering is defined.

If you want to know where a given disk volume went then you should be storing
and scanning for the disk serial number from the disk identify data combined
with the vendor and model bits. This works for just about any disk. A tiny
number of disks have no serial (all very old that I know about and almost
all CF cards), and the IT8212 raid mode emulation gets it wrong (same ident
for all raid volumes) but otherwise it works well.

For modern systems EDD will provide BIOS device mapping tables.

Alan




More information about the fedora-test-list mailing list