Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When there are no users on my system, I would like the hard disk to spindown to low-power state. I realize that this might not be 100% achievable for a straight 24 hours, but it seems reasonable that the system could remain idle for a few hours at a time when it is not in use.

My system is headless and running a limited number of services. The primary services are: exim4, mythtv-backend, nfs, samba, cups, apt-cacher-ng

Assume that drives are already enabled to go into standby mode. Also, its not acceptable to increase the write-back timeout, since my system is not on a UPS.

share|improve this question
Most drives can be set to spin down automatically using hdparm. – karthick87 Dec 28 '10 at 8:42
Whatever you do, just make sure to keep an eye on the (un)load cycle count (eg. via 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. – htorque Dec 28 '10 at 12:37
Parts of it is well described at , see under headings "Use the '-' option in /etc/syslog.conf" and "hal cdrom polling" – j-g-faustus Dec 30 '10 at 13:46
Please don't put answers in the comments. @j-g-faustus, I've tried all of these methods, plus some. Still seeing disk access, not sure where from. – cmcginty Jan 5 '11 at 1:39
See my updated reply - you can find out where disk access is coming from, but I know of no way to make the primary disk to idle without increasing the write-back timeout. – j-g-faustus Jan 5 '11 at 2:20
up vote 6 down vote accepted

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. 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.


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 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.

share|improve this answer
powertop was very helpfull! It tells you what process are writing to the disk. – cmcginty Dec 28 '10 at 21:02
hdparm -S and -B/apm does not work on the popular WD Green drives. I assume a lot of people have those now. – cmcginty Jan 5 '11 at 1:34
if syslog is disabled or written to tmpfs volume, why can't the drive go idle? – cmcginty Jan 5 '11 at 2:22
the link is bad, change to – cmcginty Jan 5 '11 at 2:24
@Casey: Don't know :) but spent some time researching this for my own system about a year ago, and the consensus seems to be that many things in Linux, from kernel to drivers to standard services and programs, were never written with power or disk saving in mind. I went the increase-writeback-timeout route myself as it seemed the simplest, and my system is almost all static data - 5 sec vs several min writeback makes little to no difference. – j-g-faustus Jan 5 '11 at 2:44

If you have sufficient RAM you can move temporary filesystems to memory, using tmpfs. Edit /etc/fstab and add:

tmpfs       /tmp        tmpfs   defaults    0   0
tmpfs       /var/run        tmpfs   defaults    0   0
tmpfs       /var/lock       tmpfs   defaults    0   0
share|improve this answer

On my laptop I mounted /var/log to a tmpfs ram drive. That gives you far less disk writes but of course any log messages are discarded upon reboot. Something you might not want when you are running services like exim.

tmpfs /var/log tmpfs defaults,noatime,mode=1777 0 0

and in /etc/rc.local

mkdir /var/log/apt

share|improve this answer

mount it with noatime

more RAM also helps (bigger buffers and caches)

share|improve this answer
noatime is valid, but there are still other processes constantly accessing the disk – cmcginty Dec 29 '10 at 0:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.