[Linux] Make HDDs spin down to safe power

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
gilthanaz
Site Admin
Posts: 444
Joined: Fri Aug 29, 2003 9:29 pm
Contact:

[Linux] Make HDDs spin down to safe power

Post by gilthanaz »

[Problem]
We got our power bill - woe is us! So much money for electricity. Well, it was time to have a look on green mode for our servers anyway. Primarily by having the clients shut down or go to sleep when no one is using them (as a lazy bastard, i've let my box basically up all year without even putting it on stand-by), and then something that comes in handy with our servers: For many hours a day, no one is home or using the servers. And even if, most stuff is handled in RAM and does not swap to the HDD. So, why not let the HDDs go to sleep if they aren't in use?


[Solution]

hdparm is your friend.

$ sudo hdparm -S 120 /dev/sda
This will set your hd to go to standby after 10 minutes. With 240, its 20 minutes, and so on. You should get this output, unless the disk is broken or weird or some mystical device in the future that is used to store data but yet, unknown:

Code: Select all

/dev/sda:

setting standby to 120 (10 minutes)

To see if everything worked, issue the following command after the timeout you specified (in this example 10 minutes) is over:

$ sudo hdparm -C /dev/sda

You should get:

Code: Select all

/dev/sda:

drive state is:* standby

Note:
If you do that to the disk where your /swap is, or the / disk in general, it will most likely be in use a lot due to SQL databases and other stuff. This solution is mostly ment for big data storage HDDs, that are not accessed that often.
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

Troubleshooting

Post by ^rooker »

In case that "hdparm -C /dev/sda" should give you depressing output
like:/dev/sda:
drive state is: unknown
You might not have sufficient access rights.
So, try running hdparm as root:

Code: Select all

sudo hdparm -C /dev/sda
Now you should get something like this:
/dev/sda:
drive state is: active/idle
Post Reply