2007-09-09

How to set hard drive power management in Ubuntu

To set Ubuntu so that a particular hard drive will power down after a certain amount of time enter the following:

sudo hdparm -S60 /dev/hda

The "hda" refers to the hard drive the command should apply to. Check your system to make sure you are referring to the right name for the drive your want (it was sda on my laptop).

The number following the S defines how long until the drive powers down as follows (from the hdparm man page):

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.


To turn on advanced power management for a hard drive:

sudo hdparm -B1 /dev/hda

According to the man page:

"Set Advanced Power Management feature, if the drive supports it. A low value [following the -B flag] means aggressive power management and a high value means better performance. A value of 255 will disable apm on the drive."


On my laptop I had to refer to /dev/sda, and a value of -B1 seemed to make the hard drive power down pretty quickly after use, while the hard drive seemed to keep running for a long time with a setting of -B5.

No comments: