I am trying to get the identity of a USB Hard Drive connected through a SATA-to-USB adapter. The little program I wrote is in Python and uses this:
def getID(dev):
HDIO_GET_IDENTITY = 0x030d
with open(dev, 'r') as fd:
buf = fcntl.ioctl(fd, HDIO_GET_IDENTITY, ' ' * 512)
fields = struct.unpack_from(struct_hd_driveid, buf)
serial_no = fields[10].strip()
fw_rev = fields[14].strip()
model = fields[15].strip()
return (serial_no, fw_rev, model)
Method I found here
The method runs successfully on my internal HDD but I get a
IOError: [Errno 22] Invalid argument
when running it on my USB connected HDD.
I couldn't find anything related to this - I assume that the operation code may be different for USB connected HDDs....
I almost forgot to say that I am running this from Ubuntu
Linux dragosmc-Lenovo-V570 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Thanks, dragosmc.