Linux: Switch a idle hard disk into standby mode
I have running a debian based multimedia server. The operating systems is installed on a compact flash card (/dev/sda), the data resides on a external USB SATA harddisk (/dev/sdb).
The (Server 🙂 ) Hardware is a Fujitsu Futro A240 ThinClient, with a power consumption of only 7W. I’m using the server for about 2 hours each day, therefore I looked for a method to save power and switch the USB disk to standby mode when its idle for while.
Check first if your hard disk supports the standby mode. Ensure that the disk is idle, otherwise the disk is immediately active again.
Switch to Standby mode
root@debdev:~# hdparm -y /dev/sdb
/dev/sdb: issuing standby command
and check it.
root@debdev:~# hdparm -C /dev/sdb
/dev/sdb: drive state is: standby
This can be done automatically if the disk is idle for a specific time. Use hdparm -S xx /dev/sdxx
The parameter -S is the timeout value. The following table (from man hdparm manpage) describes the possible values:
|1 to 240||specify multiples of 5||5 to 1200 seconds(20min)|
|241 to 251||1 to 11 units of 30 minutes||30 minutes to 5.5 hours|
|252||signifies a timeout of 21 minutes||21 minutes|
|253||sets a vendor-defined timeout period between 8 and 12 hours.||Vendor specific|
|255||is interpreted as 21 minutes plus 15 seconds. Note: some older drives may have very different interpretations of these values||21,25 minutes|
The following command line sets the timeout to 15 minutes
root@debdev:~# hdparm -S 180 /dev/sdb
/dev/sdb: setting standby to 180 (900 seconds)
You have to set the timeout each the the operating system starts. This can be done by editing the /etc/hdparm.conf file. Find an already defined and uncommented section for your disk or add a new one:
spindown_time = 180}