HDParm

HDParm is a tool to manage your drives. The first section show you how to get informations about your drives, the second tells you how to make them sleep when they aren’t used (and so make power economy). If you’ve got a home server like me with the system on a SSD, with only your big files on the hard drives(s), you’ll want to do this.

 

Get disk informations

You’ve got to use “sudo” to gain super user privilege. Your disk are in the /dev/ folder, named sd* where “*” is a letter. To see the list of disk, one can type use “ls /dev/sd[a-z]“:
debserver % ls /dev/sd[a-z]
/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde

 

To display informations about one disk, you can use “sudo hdparm -i”

 

debserver % sudo hdparm -i /dev/sda
/dev/sda:

Model=WDC WD20EFRX-68EUZN0, FwRev=80.00A80, SerialNo=WD-WCC4M1067803
Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=3907029168
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
AdvancedPM=no WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-1,2,3,4,5,6,7

* signifies the current active mode

 

Make a drive sleep after some time

From the manual (man hdparm on the command line):

-S Set the standby (spindown) timeout for the drive. This value is used by the drive to determine how long to wait (with no disk activity) before turning off the spindle motor to save power. Under such circumstances, the drive may take as long as 30 seconds to respond to a subsequent disk access, though most drives are much quicker. The encoding of the timeout value is somewhat peculiar. A value of zero means "timeouts are disabled": the device will not automatically enter standby mode. Values from 1 to 240 specify multiples of 5 seconds, yielding timeouts from 5 seconds to 20 minutes. Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding timeouts from 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21 minutes. A value of 253 sets a vendor-defined timeout period between 8 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21 minutes plus 15 seconds. Note that some older drives may have very different interpretations of these values.

 

So “sudo hdparm -I /dev/sdb | grep level” will show the current spindown value, for Example:

debserver % sudo hdparm -I /dev/sdb | grep level
Advanced power management level: 254

Example:

sudo hdparm -S 25 /dev/sdb = spindown after 25*5 seconds.

sudo hdparm -S 245 /dev/sdb = spindown after (245-240)*30 minutes.

 

If you want to check the state to see if it works :

sudo watch -n 1 "hdparm -C /dev/sdb && hdparm -C /dev/sdc && hdparm -C /dev/sdd && hdparm -C /dev/sde"

 

You can use /etc/hdparm.conf to make it permanent:
/dev/sdb {
spindown_time = 60
}