OK so I've never used the method with the scripts that some people write and you just copy them. Instead about a year ago I found this method which is the way you are supposed to do it. I've always wanted to share but was too lazy. Now I am overwhelmed with work and I am punishing myself for not sharing it earlier. I am not sure whether you can find this way online (apart from this howto) but you could search.
And just a note which I remembered in the writing process. 255 will not work on some machines. If it doesn't for yours use 254 as a value - it's the same basically.
1. You will need the packages hdparm, sysvconfig and smartmontools all of which can be obtained from the repos. Install them both.
2. You need to make sure that hdparm is started as a process when you log in. Start sysvconfig and press enter to enter Enable/Disable mode. Find hdparm and press space to place an asterisk in the brackets on the left of it. Now confirm your choice by pressing enter and make sure you save before exiting sysvconfig.
3. Now here comes the bit that I do differently. There are some files that you need to edit. These are hdparm's config file and a few scripts that are already there and are loaded when you log in. So you just need to give them the right information. To be honest I think they've changed them now so but as I haven't reinstalled my system after I found this method I can't tell you exactly. When I say change I mean that they've introduced new scripts so the old ones might not be used. However I will tell you how to edit both in case you have an old install.
(i) First comes /etc/hdparm.conf. This file is not changed so you should be able to find it. Edit it in the following way:
Code: Select all
## This is the default configuration for hdparm for Debian. It is a
## rather simple script, so please follow the following guidelines :)
## Any line that begins with a comment is ignored - add as many as you
## like. Note that an in-line comment is not supported. If a line
## consists of whitespace only (tabs, spaces, carriage return), it will be
## ignored, so you can space control fields as you like. ANYTHING ELSE
## IS PARSED!! This means that lines with stray characters or lines that
## use non # comment characters will be interpreted by the initscript.
## This has probably minor, but potentially serious, side effects for your
## hard drives, so please follow the guidelines. Patches to improve
## flexibilty welcome. Please read /usr/share/doc/hdparm/README.Debian for
## notes about known issues, especially if you have an MD array.
##
## Note that if the init script causes boot problems, you can pass 'nohdparm'
## on the kernel command line, and the script will not be run.
##
## Uncommenting the options below will cause them to be added to the DEFAULT
## string which is prepended to options listed in the blocks below.
##
## If an option is listed twice, the second instance replaces the first.
##
## /sbin/hdparm is not run unless a block of the form:
## DEV {
## option
## option
## ...
## }
## exists. This blocks will cause /sbin/hdparm OPTIONS DEV to be run.
## Where OPTIONS is the concatenation of all options previously defined
## outside of a block and all options defined with in the block.
# -q be quiet
quiet
# -a sector count for filesystem read-ahead
#read_ahead_sect = 12
# -A disable/enable the IDE drive's read-lookahead feature
#lookahead = on
# -b bus state
#bus = on
# -B apm setting
#apm = 255
# -c enable (E)IDE 32-bit I/O support - can be any of 0,1,3
#io32_support = 1
# -d disable/enable the "using_dma" flag for this drive
#dma = off
# -D enable/disable the on-drive defect management
#defect_mana = off
# -E cdrom speed
#cd_speed = 16
# -k disable/enable the "keep_settings_over_reset" flag for this drive
#keep_settings_over_reset = off
# -K disable/enable the drive's "keep_features_over_reset" flag
#keep_features_over_reset = on
# -m sector count for multiple sector I/O
#mult_sect_io = 32
# -P maximum sector count for the drive's internal prefetch mechanism
#prefetch_sect = 12
# -r read-only flag for device
#read_only = off
# -s Turn on/off power on in standby mode
#poweron_standby = off
# -S standby (spindown) timeout for the drive
#spindown_time = 0
# -u interrupt-unmask flag for the drive
#interrupt_unmask = on
# -W Disable/enable the IDE drive's write-caching feature
#write_cache = off
# -X IDE transfer mode for newer (E)IDE/ATA2 drives
#transfer_mode = 34
# -y force to immediately enter the standby mode
#standby
# -Y force to immediately enter the sleep mode
#sleep
# -Z Disable the power-saving function of certain Seagate drives
#disable_seagate
# -M Set the acoustic management properties of a drive
#acoustic_management
# -p Set the chipset PIO mode
# chipset_pio_mode
# --security-freeze Freeze the drive's security status
# security_freeze
# --security-unlock Unlock the drive's security
# security_unlock = PWD
# --security-set-pass Set security password
# security_pass = password
# --security-disable Disable drive locking
# security_disable
# --user-master Select password to use
# user-master = u
# --security-mode Set the security mode
# security_mode = h
# Root file systems. Please see README.Debian for details
ROOTFS = /dev/sda
## New note - you can use straight hdparm commands in this config file
## as well - the set up is ugly, but it keeps backwards compatibility
## Additionally, it should be noted that any blocks that begin with
## the keyword 'command_line' are not run until after the root filesystem
## is mounted. This is done to avoid running blocks twice. If you need
## to run hdparm to set parameters for your root disk, please use the
## standard format.
#Samples follow:
#First three are good for devfs systems, fourth one for systems that do
#not use devfs. The fifth example uses straight hdparm command line
#syntax. Any of the blocks that use command line syntax must begin with
#the keyword 'command_line', and no attempt is made to validate syntax.
#It is provided for those more comfortable with hdparm syntax.
#/dev/discs/disc0/disc {
# mult_sect_io = 16
# write_cache = off
# spindown_time = 240
#}
#/dev/discs/disc1/disc {
# mult_sect_io = 32
# spindown_time = 36
# write_cache = off
#}
#/dev/cdroms/cdrom0 {
# dma = on
# interrupt_unmask = on
# io32_support = 0
#}
#/dev/hda {
# mult_sect_io = 16
# write_cache = off
# dma = on
#}
#command_line {
# hdparm -q -m16 -q -W0 -q -d1 /dev/hda
#}
/dev/sda
{
apm = 255
spindown_time = 0
dma = on
}
(ii) Here come some new files. Basically I don't know why you need those after editing the hdparm.conf but they are there, they are loaded so we might just load the right things, right? This file is the old one. This is the APM script. APM is a power management which as I understand is no longer supported. When I compiled a kernel 5 months ago it said that they are dropping it. In case you use an old kernel here is what you have to do (if you do not have the following files don't worry a bit - you don't need them).
Code: Select all
cd /etc/apm/event.d
ls
nano 20hdparm ## in the unlikely event that after ls you get something else containing hdparm use that one
Code: Select all
APMD_DRIVES=sda ##Again put YOUR device
Code: Select all
power_performance ()
{
# Disable IDE hard disk spindown.
for DRIVE in $APMD_DRIVES; do
"${HDPARM}" -q -S 0 -B 255 "${DRIVE}" || true
done
}
(iii) Ok here is the last bit. It is for ACPI power management. Unless you are running some ald and forgotten kernel this is what you should have.
Code: Select all
cd /etc/acpi/ac.d
ls
nano 90-hdparm.sh ## or whatever ls shows you
Code: Select all
for dev in /dev/sd? /dev/hd? ; do
if [ -b $dev ] ; then
# Check for APM support; discard errors since not all drives
# support HDIO_GET_IDENTITY (-i).
if hdparm -i $dev 2> /dev/null | grep -q 'AdvancedPM=yes' ; then
if [ $STATE = "BATTERY" ] ; then
hdparm -B 128 $dev
else
hdparm -B 255 $dev
fi
fi
fi
done
fi
4. Reboot
5. Finally confirmed that it worked. Do
Code: Select all
smartctl -a /dev/sda | grep Load_Cycle_Count
Code: Select all
smartctl -a -d ata -i /dev/sda | grep Load_Cycle_Count
NB There is one thing which I noticed today and I'll probably solve in a few days. What I am talking about is that (at least on my machine) hdparm doesn't load if I resume from suspend. In such case I do (manually):
Code: Select all
hdparm -B 255 -S 0 /dev/sda