71 lines
2.0 KiB
Bash
71 lines
2.0 KiB
Bash
#!/bin/bash
|
|
# Hdparm initscript - Turn on harddisk optimization
|
|
# Copyright (C) 2004-2005 Silvan Calarco <silvan.calarco@qilinux.it>
|
|
# Copyright (C) 2004-2005 Davide Madrisan <davide.madrisan@qilinux.it>
|
|
#
|
|
# hdparm: Set hard disk parameters
|
|
# chkconfig: 2345 09 93
|
|
# description: Set hard disk parameters
|
|
|
|
. /etc/sysconfig/rc
|
|
. $rc_functions
|
|
|
|
# There is only one file /etc/sysconfig/harddisks for all disks after
|
|
# installing the hdparm package.
|
|
# If you need different hdparm parameters for each of your disks, copy
|
|
# /etc/sysconfig/harddisks to /etc/sysconfig/harddiskhda (hdb, hdc...)
|
|
# and modify it.
|
|
# Each disk which has no special parameters will use the defaults.
|
|
# For each cdrom only the 'EIDE_32BIT' parameter will be used
|
|
|
|
case "$1" in
|
|
start)
|
|
[ -x /sbin/hdparm ] || exit 0
|
|
|
|
for device in $(find /dev/hd[a-z] -printf "%f " 2>/dev/null); do
|
|
unset MULTIPLE_IO USE_DMA EIDE_32BIT LOOKAHEAD EXTRA_PARAMS
|
|
if [ -r /etc/sysconfig/harddisk${device} ]; then
|
|
. /etc/sysconfig/harddisk${device}
|
|
else
|
|
# use default values
|
|
[ -r /etc/sysconfig/harddisks ] && . /etc/sysconfig/harddisks
|
|
fi
|
|
|
|
unset HDFLAGS
|
|
if [ -r "/proc/ide/$device/media" ]; then
|
|
case "$(cat /proc/ide/$device/media)" in
|
|
"disk")
|
|
[ "$MULTIPLE_IO" ] &&
|
|
HDFLAGS="-q -m$MULTIPLE_IO"
|
|
[ "$USE_DMA" ] &&
|
|
HDFLAGS="$HDFLAGS -q -d$USE_DMA"
|
|
[ "$EIDE_32BIT" ] &&
|
|
HDFLAGS="$HDFLAGS -q -c$EIDE_32BIT"
|
|
[ "$LOOKAHEAD" ] &&
|
|
HDFLAGS="$HDFLAGS -q -A$LOOKAHEAD"
|
|
[ "$EXTRA_PARAMS" ] &&
|
|
HDFLAGS="$HDFLAGS $EXTRA_PARAMS"
|
|
;;
|
|
"cdrom")
|
|
[ "$EIDE_32BIT" ] &&
|
|
HDFLAGS="$HDFLAGS -q -c$EIDE_32BIT"
|
|
;;
|
|
esac
|
|
fi
|
|
[ "$HDFLAGS" ] &&
|
|
action $"Setting hard drive parameters for $device: " \
|
|
/sbin/hdparm $HDFLAGS /dev/$device
|
|
done
|
|
;;
|
|
restart)
|
|
$0 start
|
|
;;
|
|
stop)
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart}"
|
|
exit 1
|
|
;;
|
|
esac
|