hdparm lets you set the spindown time for a drive (how long period of inactivity
before the disk goes to standby mode) or put it in standby or to sleep.
# set spindown time for sda drive to 1 min
sudo hdparm -S 12 /dev/sda
# set sdb drive to standby mode
sudo hdparm -y /dev/sdb
# put sdc drive to sleep
sudo hdparm -Y /dev/sdc
# check drive state (active/standby/sleeping)
sudo hdpam -C /dev/sdc
/etc/hdparm.conf contains hdparm commands to run automatically at bootup. Here's a snippet from mine:
/dev/sda {
# apm 127: Highest performance that allows spindown
apm = 127
# spindown 120 = 10 min
spindown_time = 120
}
Not all commands work on all hard drive models, you need to experiment.
laptop-mode works for non-laptops too, it is meant to let the disk(s) sleep as much as possible.
PowerTOP is a utility for tracking down unnecessary background activity.
lesswatts.org has a number of tips on harddrive spindown.
write-back timeout: To the best of my knowledge it is not possible to have the primary disk go idle without a) increasing the write-back timeout and b) disabling syslog sync.
A workaround could perhaps be to have an SSD as the root disk, as they are fairly low on power anyway?
tracking activity: It is possible to debug where disk access is coming from according to the laptop-mode FAQ - see 5 Spinup Debugging.
Quote:
My disk spins up all the time and I
have no clue what causes this. Can I
debug this?
Yes, you can. But first,
check that you have modified your
syslog.conf to not sync, as described
in the last question of the previous
section. To debug disk activity, you
can do:
echo 1 > /proc/sys/vm/block_dump
(Warning: you must disable syslogd before you do this,
or you must make
sure that kernel output is not logged.
If you forget this, your system may
get into a feedback loop, where
syslogd causes disk activity, this
causes kernel output, and this causes
syslogd to do more disk activity,
etcetera!)
This enables file/disk activity
debugging in the kernel. You can read
the output using dmesg. When you're
done, disable block dump using
echo 0 > /proc/sys/vm/block_dump
disabling syslogd sync: The laptop-mode FAQ and lesswatts.org refer to /etc/syslog.conf
.
In recent Ubuntu this file does not exist, instead look for /etc/rsyslog.d/*.conf
.
The syntax is the same - prepend every log file with a dash, like this:
kern.* -/var/log/kern.log
This turns off syncing for the syslog deamon, meaning that the logs will be written to disk at dirty_writeback_centisecs
intervals (every 5 sec by default) instead of every time there is new log entry.
sudo smartctl -a /dev/sda
, S.M.A.R.T. value "Load Cycle Count"). Spinning the disk up and down will increase this value - a typical lifetime limit is 600,000.