After replacing the optical drive of my MacBook Pro (mid 2012) with a SATA-II HDD, I'm having trouble with the HDD's annoying head parking after short intervals of usage. Since I'm using the MacBook almost exclusively as a desktop replacement, I do neither need that for power-efficiency nor vibration-safety reasons.
I've set the APM-level to maximum performance (e.g. 254, no head parking) via McKinlay's tool hpapm and got 01.12.14 10:05:06,503 hdapm[93]: Set APM Level to 0xfe: Success in OSX's console, yet the HDD head keeps parking after about 10 seconds of idling, so please avoid standard-suggestions based on hdapm.
I then made a launchd daemon running upon login the following shell script.
#!/bin/sh
while true; do touch /Volumes/Data/somefolder; sleep 6; done
By touching some folder on a partition Data on the HDD every 6 seconds, the head is obviously prevented from parking, but may on the downside continuously have to jump to that location even under high HDD-I/O.
I'd now like to refine that solution by limiting this "keep-alive" script to phases of HDD-idle.
Using e.g. sudo fs_usage | grep "/Volumes/Data" I can get a log of the I/O on that partition. I now want to start a timer on every I/O message and execute the above script after a pre-defined amount of time if no further I/O messages occur.
Can you give me a hand on that or suggest a better way to prevent head parking?