Fun with hdparm!

The hdparm utility reports on and set device parameters. This blog explains a few of the hdparm options—see the man page for more options and details.

CAUTION: You can wreak havoc on a disk with some hdparm commands. You can wipe a disk with a hdparm Secure Erase command (see https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase). Use this utility with caution.

If you want more information than this blog hosts, see the hdparm man page, http://freshmeat.net/projects/hdparm/, and http://sourceforge.net/projects/hdparm/.

In the following examples, /dev/sdf is a Hitachi 1TB drive model HDS721010CLA332.

Display General Information

The –I option displays information about a drive. Add – –verbose for even more information.

$ sudo hdparm -I /dev/sdf | head -20
/dev/sdf:
ATA device, with non-removable media
        Model Number:       Hitachi HDS721010CLA332
        Serial Number:      JP2921HQ049J1A
        Firmware Revision:  JP4OA25C
        Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6; Revision: ATA8-AST T13 Project D1697 Revision 0b
Standards:
        Used: unknown (minor revision code 0x0029)
        Supported: 8 7 6 5
        Likely used: 8
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:   16514064
        LBA    user addressable sectors:  268435455

With the –H option, hdparm displays the temperature of the drive you specify as an argument. It also tells you whether the drive temperature is in a safe range, which may not be accurate. This option works for Hitachi drives and may work for some others.

$ sudo hdparm -H /dev/sdf
/dev/sdf:
  drive temperature (celsius) is:  29
  drive temperature in range:  yes

Control Power Settings

The –C option displays the power setting of the drive:

mark@tea:~$ sudo hdparm -C /dev/sd[ef]
/dev/sde:
 drive state is:  active/idle
/dev/sdf:
 drive state is:  standby

Although the man page refers to a sleep and a standby mode, I could get my drive to report only standby. The –Y option is supposed to put a drive into the lowest power mode (sleep), which means it shuts down completely. The –y option is supposed to put a drive into the low power mode (standby), which usually means it spins down.

$mark@tea:~$ sudo hdparm -C /dev/sdf
/dev/sdf:
 drive state is:  active/idle
mark@tea:~$ sudo hdparm -Y /dev/sdf
/dev/sdf:
 issuing sleep command
mark@tea:~$ sudo hdparm -C /dev/sdf
/dev/sdf:
 drive state is:  standby

Before testing another option, I spin up the hard drive by listing a directory on the hard drive. Five-ten seconds elapse before the listing appears, confirming the drive was spun-down. If you do not see this pause, the drive is not spun-down or you are reading from cache.

mark@tea:~$ ls -l /backup/bu1/*/p01.26
...
mark@tea:~$ sudo hdparm -C /dev/sdf
/dev/sdf:
 drive state is:  active/idle
>>> Mon 17:05
mark@tea:~$ sudo hdparm -y /dev/sdf
/dev/sdf:
 issuing standby command
>>> Mon 17:05
mark@tea:~$ sudo hdparm -C /dev/sdf
/dev/sdf:
 drive state is:  standby

With an argument of 0 (zero), the –S option prevents the drive from entering low-power mode and spinning down. The numeric arguments cause the drive to spin down after a specified period of inactivity. An argument in the range of 1-240 causes the drive to spin down after nx5 seconds (120 causes the drive to spin down after 10 minutes of inactivity). An argument in the range 241-251 cause the drive to spin down after (n-240)x30 minutes. These values may vary between drive manufacturers.

Performance Testing

The –T and –t options yield benchmarks for the drive. The uppercase option displays cache read benchmarks while the lowercase option displays device read benchmarks.

mark@tea:~$ sudo hdparm -Tt /dev/sdf
/dev/sdf:
 Timing cached reads:   15200 MB in  2.00 seconds = 7609.46 MB/sec
 Timing buffered disk reads:  408 MB in  3.01 seconds = 135.52 MB/sec
This entry was posted in Hard disk, Sysadmin. Bookmark the permalink.