Search code examples
diskseek

Seek Command on hard disk


I've got a problem in seeking on the hard drive.

I wonder how to do a serial of SEEK operations with out reading or writing on a hard drive. It's just like the work in the papaer "Modeling Hard-Disk Power Consumption". I need a tool, an interface or a single command to seek the specify address on the disk like a LBA or a cylinder address.

I want to figure out the seek distance of the hard disk using this command without data transferring. Because I need to draw a curve of the seek distance and energy according to the experiment.

A SEEK command and the seek distance in cylinder format is what I need. Both linux and windows are OK. Please give me a hand.


Solution

  • Seeking isn't part of the usual block device API, so you will need to issue a device-specific command to perform a seek. For convenience, USB and IDE/SATA have both chosen to use the SCSI command set for such commands, so you need to refer to the SCSI standards.

    This is at least partly why such devices show up on Linux as SCSI disks named /dev/sdX with corresponding "SCSI generic" devices at /dev/sgN. FreeBSD provides a similar API, MS-DOS and Windows have ASPI and friends, and you're out of luck on MacOS X unless you write your own kernel driver (and for Yosemite, get it signed.)

    So the two pieces you need are how to program Linux's SG devices:

    ...and the SCSI standards. These are expensive proprietary standards issued by T10 but some creative search queries should find you draft or otherwise hooky copies. The one describing SCSI in general is called "Information technology - SCSI Primary Commands - 4 (SPC-4)" and that relating to hard disks and similar media is "Information Technology - SCSI Block Commands - 2 (SBC-2)". (Future versions of these would be called SPC-5, -6 etc.) The specific command for seeking is described in the latter document, and the one you want is called SEEK(10). SEEK(6) is a legacy command that only supports small disks and is probably not well-supported on non-SCSI devices.