What is keeping my disks awake?

4

I have configured my hard drives to go to sleep after 1 minute of inactivity. This used to work very well; the server was almost always dead silent. But recently the drives are more often awake.

Can I check what is keeping them from going to sleep? This is a home server.

rc.local:

hdparm -M 128 -S 60 /dev/sda
hdparm -S 60 /dev/sdb

Update: The server is running Ubuntu 10.04. The OS, with /tmp and /var/, is on an SSD, while sda and sdb are only used for storage/backup.

Update 2: From my sysctl.conf:

vm.swappiness = 1
vm.vfs_cache_pressure = 50
vm.dirty_writeback_centisecs = 1500
vm.dirty_ratio = 20
vm.dirty_backgrounds_ratio = 10

Znarkus

Posted 2010-10-09T08:47:49.813

Reputation: 937

1Are you aware that by spinning down the drives you're shortening their already short lives? – None – 2010-10-09T11:27:48.393

@John: do you have a solid reference for that? I've seen it argued both ways. @Znarkus: I guess you're running Linux, from your use of hdparm, but you should state your OS explicitly in your question. – Gilles 'SO- stop being evil' – 2010-10-09T12:13:20.997

Most disk wear is from the heat-up/cool-down cycle. The less you do that, the longer it will last. – Chris S – 2010-10-09T15:30:11.667

@Gilles, I don't know of a reference you can look up but personal experience of nearly 4 decades, as well as an understanding of why the wear takes place, is kind of hard to ignore. – None – 2010-10-09T21:34:25.373

@John: I've learnt to be wary of this kind of “conventional wisdom” — the same that claims that hard drives should run as cool as possible (which turned out to be false). I've asked for quantitative data in a separate question.

– Gilles 'SO- stop being evil' – 2010-10-10T12:16:08.953

That is very interesting. But as non solid state disks make so much noise and produces heat from their relative high energy consumption, I can't have them spinning all day. I've updated the question with more information – Znarkus – 2010-10-12T10:56:42.167

Answers

3

This isn't really an answer to the question you ask, but may help with the underlying issue. One tool I know of is iotop, but it might not help to catch brief activity from a process.

Getting hard drives to sleep when idle can be difficult, because there are so many potential sources of activity. Just because you think your system is doing nothing doesn't mean something isn't writing in the background. Here are a few common culprits:

  • Journal flushing. Linux flushes the ext3 (or ext4) journal at regular intervals whether it needs flushing or not. This can be tuned with the commit mount option.
  • System logs. Under a default configuration, some system logs are flushed whenever a line is written. Cron jobs are habitual offenders because they trigger an auth log entry. You'll want a - before all log file names in /etc/syslog.conf.

If you really want your disks to spin down, check out noflushd. It really works (or at least it used to, it hasn't been maintained much lately and might have issues with contemporary kernels). But beware that it's a hack, and it's really heavy-handed: it simply stops the kernel from writing until either the cache is full or the disk wakes up anyway for a read.

If you're looking for silence, a technique that helps a lot is to suspend the disks from elastics instead of mounting it directly. This won't help reduce power consumption, but unless you have ≥10krpm drives (which require a screamer of a fan anyway), the CPU and motherboard are probably the main power drains even when idle.

Gilles 'SO- stop being evil'

Posted 2010-10-09T08:47:49.813

Reputation: 58 319

Thanks for all advices. Can I make ´iotop´ show on what drive the activity is? – Znarkus – 2010-10-12T15:42:47.720

@Znarkus: I don't think so, but if you've found that a particular process is doing I/O, you can use lsof or strace to find what files it has open or opens. – Gilles 'SO- stop being evil' – 2010-10-12T17:40:40.310

3

Make sure you've turned off any verbose logging. If you have machines that are sending out broadcasts on particular ports that are logged by your firewall rules, you'll easily get an entry enough that the drive won't spin down. HP Printers and Windows machines are notorious for sending out broadcasts to check for other machines on the local network and most firewall rules log those requests.

Check the services you have running to see if any might be logging to their own files. Do you have fam running? swappiness set high and enough services that you're constantly shuffling things from ram to swap? cron jobs?

karmawhore

Posted 2010-10-09T08:47:49.813

Reputation:

1

have you tried iotop?

Hubert Kario

Posted 2010-10-09T08:47:49.813

Reputation: 390