But HDAPS doesn't work 'out of the box' on Linux by default. On my Debian too. But there is so indispensable website named ThinkWiki with the tons of information how to make Linux and ThinkPad friends forever. And there is a cool article how to enable HDD APS (http://www.thinkwiki.org/wiki/How_to_protect_the_harddisk_through_APS): just compile few modules and install a special daemon -- nothing difficult. And APS will begin to work. Every time.
But there are cases when there are no need in active HDD protection when laptop is running from AC but required when the battery mode. How to handle this? The answer is to use capabilities of pm-utils package -- it allows to make hooks on special events like 'Laptop is on battery more' or vice-versa. So here a little tip'n'trick.
1. Create an executable hdaps file in /etc/pm/power.d folder with the following contents:
#!/bin/sh
HDAPS_MODULES="thinkpad_ec tp_smapi hdaps"
HDAPSD_INIT_SCRIPT=/etc/init.d/hdapsd
MODPROBE=/sbin/modprobe
RMMOD=/sbin/rmmod
case "$1" in
### CASE: Work on battery
true)
echo "Enabling HDAPS"
for module in $HDAPS_MODULES; do
$MODPROBE $module
done
$HDAPSD_INIT_SCRIPT start
;;
### CASE: Work on AC-adapter
false)
echo "Disabling HDAPS"
$HDAPSD_INIT_SCRIPT stop
### NOTE: modules should be unloaded in the reverse order
for module in `echo $HDAPS_MODULES | tac -s' '`; do
$RMMOD $module
done
;;
esac
2. Disable hdaps modules autoloading from /etc/modules3. Disable hdapsd daemon autorunning on system startup: # update-rc.d -f hdapsd remove
That's all! On Battery the script will load required HDAPS modules and run the daemon. Or will stop the daemon and unload the corresponding modules otherwise.
Tested and works well for my Debian Squeeze and Thinkpad T410.
No comments:
Post a Comment