Question: Can I have stronger laptop mode in Linux?
I want to spin down the hard drive and prevent it to spin up even if something wants to read something not in cache. In general I want to have these modes:
I also want to have access times tracked (mount -o atime), but I don’t want the hard drive to be spinned up only to update them.
Is there some settings or kernel patches that can get closer to this?
May be I should write special io scheduler for “forced laptop mode”? E.g. echo suspend > /sys/block/sda/queue/scheduler to lock the drive and echo cfq > /sys/block/sda/queue/scheduler to unlock it again?
Answer: Quickly coded the “forced laptop mode” as io scheduler. Tested first in UML, then on my laptop even without a reboot.
http://vi-server.org/vi/0001-block-Introduce-hung-iosched.patch
When I issue echo hung > /sys/block/sda/queue/scheduler, followed by hdparm -y /dev/sda the hard drive stops and don’t resumes.
When I need to read something I just do “echo cfq > /sys/block/sda/queue/scheduler.
Also I can see what processes are wanting to cause spinup (they are D-sleeping). reiserfs and pdflush gets hung. Then syslogd.
To prevent sync attempts I temporarily disable syncs echo 0 > /proc/sys/fs/sync-enable. It should be more or less safe given hard drive is already locked up. This is provided by http://vi-server.org/vi/0001-fs-Introduce-sync-enable-flag.patch.