I installed
Ubuntu Hardy Heron Beta in my laptop to test. I installed smartmontools and checked if the load cycle count increases. It did not increase until I did a suspend/resume which works very well in Ubuntu. I googled to find a fix for the high frequency of load cycle count after suspend and resume. Since Ubuntu Hardy uses pm utils the ugly fix from ubuntu demon did not seem to work.
http://ubuntuforums.org/showpost.php?p=3675960&postcount=26 I found two links from novel bugzilla and redhat bugzilla
https://bugzilla.novell.com/show_bug.cgi?id=338230 https://bugzilla.redhat.com/show_bug.cgi?id=382061 I integrated the above two fixes in three shell script files. I copied the three script files into /etc/pm/config.d, /etc/pm/power.d, /etc/pm/sleep.d and tested suspend/resume Surprise, the fix started working in
Ubuntu Hardy Heron Beta The script names are pm-disk, diskpr and disksr The following is my effort to explain what I did and where to copy the scripts to make it work
Configuration Script taken from Novel Bugzilla Link: pm-disk --> same script which is found in novel bugzilla (power management config script), to be copied into /etc/pm/config.d/ create a file called
pm-disk with the following contents
# Configure disk power management settings to ensure both
# long disk life and good power management.
#
# Space delimited list of disk devices this affects.
#
DEVICES_DISK_PM_NAMES="/dev/sda"
#
#
# Power management modes
#
# Powersave mode off
# Disable APM and spin-down
#
DEVICES_DISK_PM_POWERSAVE_OFF="hdparm -q -B 255 -q -S 0"
#
# Powersave mode on
# Enable APM to conservative 200 and set spin-down for 21 minutes
#
DEVICES_DISK_PM_POWERSAVE_ON="hdparm -q -B 200 -q -S 252"
give the file executable permission, chmod +x pm-disk from the folder where the script is saved. Just copy the script to /etc/pm/config.d/ using the following command. Thanks to comments from "Hai", there is no need to give executable permission to pm-disk
source
sudo cp pm-disk /etc/pm/config.d/
Action Script for Power Management taken from Novel Bugzilla Link:
diskpr --> renamed script disk to diskpr meaning actionscript for disk power(power management switch from AC to Battery), to be copied into /etc/pm/power.d/ create a file called
diskpr with the following contents (Correction: the 3rd line of the following script was using . /etc/pm/config.d/disk and changed to use . /etc/pm/config.d/pm-disk, Thanks to comments from "Hai" (see comments 3 to 5))
#!/bin/bash
. /usr/lib/pm-utils/functions
. /etc/pm/config.d/pm-disk
if test -z ${DEVICES_DISK_PM_NAMES}; then
exit 1
fi
case "$1" in
true)
echo "**enabled pm for harddisk"
for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do
${DEVICES_DISK_PM_POWERSAVE_ON} ${DISK_NAME}
done ;;
false)
echo "**disabled pm for harddisk"
for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do
${DEVICES_DISK_PM_POWERSAVE_OFF} ${DISK_NAME}
done ;;
esac
give the file executable permission,
chmod +x diskpr from the folder where the script is saved. Copy the script to
/etc/pm/power.d/ using the following command
sudo cp diskpr /etc/pm/power.d/
sudo chmod +x /etc/pm/power.d/diskpr
Suspend/Resume handling Script adopted based on Redhat Bugzilla Link: disksr --> the script is created with a slight modification to adapt the one like suse script for handling suspend/resume and named disksr (sr stands for suspend resume), to be copied into /etc/pm/sleep.d/ create a file called
disksr with the following contents (Correction: the 3rd line of the following script was using . /etc/pm/config.d/disk and changed to use . /etc/pm/config.d/pm-disk, Thanks to comments from "Hai" (see comments 3 to 5))
#!/bin/bash
. /usr/lib/pm-utils/functions
. /etc/pm/config.d/pm-disk
if test -z ${DEVICES_DISK_PM_NAMES}; then
exit 1
fi
case "$1" in
hibernate|suspend)
echo "**enabled pm for harddisk"
for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do
${DEVICES_DISK_PM_POWERSAVE_ON} ${DISK_NAME}
done ;;
thaw|resume)
echo "**disabled pm for harddisk"
for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do
${DEVICES_DISK_PM_POWERSAVE_OFF} ${DISK_NAME}
done ;;
esac
give the file executable permission,
chmod +x disksr from the folder where the script is saved. Copy the script to /etc/pm/sleep.d/ using the following command
sudo cp disksr /etc/pm/sleep.d/
sudo chmod +x /etc/pm/sleep.d/disksr
Many thanks to Redhat, Novel Bugzilla and Ubuntuforums which helped get this fix work for Ubuntu Hardy Heron
Beta (I am using Ubuntu Hardy Heron now) in my laptop Hope the scripts will work for you if you use Ubuntu Hardy Heron or latest Fedora or openSUSE.
Corrections
1. No need to add executable rights to pm-disk config script.
Thanks to comments from "Hai"
2. Change the disksr and diskpr files
to include /etc/pm/config.d/pm-disk instead
of /etc/pm/config.d/disk. Thanks to comments from "Hai"
3. To have a default hdparm value of 254 or 255 set and
standby value to 0, without calling these scripts initially,
change the values in /etc/acpi/power.sh In the
script /etc/acpi/power.sh which is present
by default in Ubuntu Hardy 8.04, I changed the
function laptop_mode_disable as follows
function laptop_mode_disable {
for x in /sys/bus/ide/devices/*/block*; do
drive=$(basename $(readlink $x));
$HDPARM -S 0 /dev/$drive 2>/dev/null
$HDPARM -B 255 /dev/$drive 2>/dev/null
done
for x in /sys/bus/scsi/devices/*/block*; do
drive=$(basename $(readlink $x));
$HDPARM -S 0 /dev/$drive 2>/dev/null
$HDPARM -B 255 /dev/$drive 2>/dev/null
done
$LAPTOP_MODE stop
}
The change includes passing 255 (or 254 if 255 does not work for you) after -B
and 0 after -S
P.S:
I am very new to blogging eventhough I am using linux distros in my PC/Laptop for more than three years, so there will be mistakes and typo, which I hope you will not mind