Home page of this blog

Thursday, June 17, 2010

Ubuntu Linux 10.04 - How to put unused harddisk into standby mode

This article explains how to make your unused harddisk into idle mode to save power and increase lifetime of that harddisk

I have two harddisks, one for windows and one for linux. Though windows harddisk is hardly used when I am in Ubuntu linux, it is still in active mode. What it means is harddisk is spinning always though it is not being accessed by me or by the operating system. In case of windows harddisk, it is not even mounted but still spinning always.

Setting harddisk to standby mode will increase the lifetime of unused harddisk and also consumes less power. This will also decrease the amount of heat generated by the spinning harddisk. As a side effect your acoustics will be improved. Though the harddisk is in standby mode, it will wake up when you mount it or when you try accessing files.

I did the following to bring the unused harddisk to standby or idle mode.

sudo hdparm -S 12 /dev/sdb

S accepts a time unit which tells the harddisk to be brought down to standby mode, if the harddisk is not accessed by any program within the unit of time. The value of S here is 12 which means, the harddisk is brought down to standby if not accessed within 1 minute. The following info (goto bottom of this page to see the values possible and more about -S if you dont want to give man hdparm) from the hdparm manual tells more about -S than my words

/dev/sdb tells the harddisk to be brought down to standby. Change sdb to sda or sdc or whichever harddidsk you want to bring to standby.

To verify if the harddisk state, you can use hdparm -C

sudo hdparm -C /dev/sdb

will print the current state of harddisk sdb (see screenshot below)

To do this automatically everytime Ubuntu boots, I added this line inside my /etc/rc.local file

sudo vi /etc/rc.local

and add the following line before last line

hdparm -S 12 /dev/sd<N>

where <N> should be replaced with a or b or c or d or .. based on your harddisk

See the following screenshot of my /etc/rc.local file to know how it should look (it should look similar, dont blindly copy the harddisk names, your harddisks may be different like sdb may be linux and sda may be windows or .... any permutations and combinations)

-S option description below taken from man hdparm

Put the drive into idle (low-power) mode, and also set the standby (spindown) timeout for the drive.  This timeout 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 time‐
out 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.

No comments:

Post a Comment