I don't know, but I am guessing that there is nothing you can do about this. Here's my reasoning:
When you say "system disk", I imagine that you mean the disk that holds the root file system.
The root file system holds several directories and files which are monitored by various utilities, including /etc/cron.*
which is watched and acted upon by cron. You probably could put /etc on a file system different from /, but it almost certainly would be more trouble than it's worth, and it certainly isn't a common setup.
/proc/diskstats
includes disk read activity, not only writes.
Every time cron executes your script to check if there has been any disk activity, that almost certainly results in multiple reads from (even if not writes to) various locations: crontabs, command interpreters, libraries used by these, etc. Unless you are running your system with noatime
, these reads also result in writes to update the access time timestamps on the files/inodes in question.
Thus, every time your script executes to check whether there has been any disk activtiy according to /proc/diskstats, that in itself results in disk activity according to /proc/diskstats. Your criteria of "no changed values" thus will never be met, and the drive will never spin down.
If this is a major concern to you, I would suggest moving everything that does not absolutely have to be on the root file system to a different file system, and run the root file system off a SSD or flash device, perhaps even mounted read-only. That should allow the spinning-platter drive to shut down at times when there is no explicit activity. However, I imagine that doing so is likely more trouble than it's worth. If you just want the drives to spin down to get rid of the noise, moving what you now have on the root file system to a small solid-state device (SSD or flash) will likely accomplish the same thing with considerably less effort. Just take into account the fact that those have a limited number of write cycles before failure (at a minimum, consider running with noatime
, or with a file system designed with SSDs in mind).
Ok well, this makes sense, i forgot about reads to the root filesystem at all... well ok then it'll be the data drives that can go to standby only. Not quite perfectly what i wanted but i guess everything else would be a little bit overkill now. – bardiir – 2012-10-03T10:14:21.033