Spindown disc profile - set disc to minimum spins.
Writen-by: Daniel Mach Rewrite-into-profile: Marcela Mašláňová
This commit is contained in:
parent
1b04250db9
commit
c2486397a9
5 changed files with 238 additions and 0 deletions
14
tune-profiles/spindown-disk/README
Normal file
14
tune-profiles/spindown-disk/README
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
Possible problems:
|
||||||
|
The script is remounting your ext3 fs if you have
|
||||||
|
it as noatime. Also configuration of rsyslog is
|
||||||
|
changed to not sync. hdparm is setting disc to
|
||||||
|
minimal spins but without use of tuned daemon.
|
||||||
|
Bluetooth will be switch off.
|
||||||
|
Wifi will be switch into power safe mode.
|
||||||
|
Usecase:
|
||||||
|
Safe extra energy on your laptop or home server
|
||||||
|
which wake-up only when you ssh to it. On server
|
||||||
|
could be hdparm and sysctl values problematic for
|
||||||
|
some type of discs. Laptops should be probably ok
|
||||||
|
with these numbers.
|
||||||
|
|
||||||
143
tune-profiles/spindown-disk/ktune.sh
Executable file
143
tune-profiles/spindown-disk/ktune.sh
Executable file
|
|
@ -0,0 +1,143 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Author of original script: Daniel Mach
|
||||||
|
# Rewrite into profiles by: Marcela Mašláňová
|
||||||
|
|
||||||
|
ALPM="medium_power"
|
||||||
|
|
||||||
|
# Set ALPM for all host adapters that support it
|
||||||
|
set_alpm() {
|
||||||
|
for x in /sys/bus/scsi/devices/host*/scsi_host/host*/; do
|
||||||
|
hotplug="0"
|
||||||
|
if [ -e $x/sata_hotplug ]; then
|
||||||
|
hotplug="$(cat $x/sata_hotplug)"
|
||||||
|
fi
|
||||||
|
if [ "$hotplug" == "0" -a -e $x/link_power_management_policy ]; then
|
||||||
|
echo $1 > $x/link_power_management_policy
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
remount() {
|
||||||
|
OPTS=$1
|
||||||
|
|
||||||
|
mount | grep 'type ext3 (' | while read LINE; do
|
||||||
|
DEV=$(echo $LINE | sed 's@^\(.*\) on .* type .*$@\1@')
|
||||||
|
MNT=$(echo $LINE | sed 's@^.* on \(.*\) type .*$@\1@')
|
||||||
|
mount -o remount,$1 $DEV $MNT
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
hdd_apm() {
|
||||||
|
APM=$1
|
||||||
|
|
||||||
|
for DEV in /dev/[sh]d[a-z]; do
|
||||||
|
hdparm -B $APM $DEV >/dev/null 2>&1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
hdd_spindown() {
|
||||||
|
SPINDOWN=$1
|
||||||
|
|
||||||
|
for DEV in /dev/[sh]d[a-z]; do
|
||||||
|
hdparm -S $SPINDOWN $DEV >/dev/null 2>&1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wireless_powersave() {
|
||||||
|
POWER=$1
|
||||||
|
|
||||||
|
IFACES=$(cat /proc/net/wireless | grep -v '|' | sed 's@^ *\([^:]*\):.*@\1@')
|
||||||
|
for IFACE in $IFACES; do
|
||||||
|
iwpriv $IFACE set_power $POWER
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
dont_sync_logs() {
|
||||||
|
cp -p /etc/rsyslog.conf /etc/rsyslog.conf.bckp
|
||||||
|
sed 's/ \/var\/log/-\/var\/log/' /etc/rsyslog.conf.bckp > /etc/rsyslog.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
revert_logs() {
|
||||||
|
mv /etc/rsyslog.conf.bckp /etc/rsyslog.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
# redirect cron to tty8 isn't probably needed anymore
|
||||||
|
|
||||||
|
set_alpm ${ALPM}
|
||||||
|
# Enables USB autosuspend for all devices
|
||||||
|
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done
|
||||||
|
# Disable HAL polling of CDROMS
|
||||||
|
for i in /dev/scd*; do hal-disable-polling --device $i; done
|
||||||
|
hciconfig hci0 down; modprobe -r hci_usb
|
||||||
|
dont_sync_logs
|
||||||
|
wireless_powersave 1
|
||||||
|
hdd_spindown 6
|
||||||
|
hdd_apm 128
|
||||||
|
remount commit=600,noatime
|
||||||
|
find /etc/ >/dev/null 2>&1
|
||||||
|
sync
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Disable ALPM for all host adapters that support it
|
||||||
|
stop() {
|
||||||
|
set_alpm "max_power"
|
||||||
|
modprobe hci_usb; hciconfig hci0 up
|
||||||
|
wireless_powersave 0
|
||||||
|
revert_logs
|
||||||
|
hdd_spindown 0
|
||||||
|
hdd_apm 255
|
||||||
|
remount commit=5
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reload it, just start once more
|
||||||
|
reload() {
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
# Status
|
||||||
|
status() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
[ -f "$VAR_SUBSYS_KTUNE" ] && exit 0
|
||||||
|
start
|
||||||
|
RETVAL=$?
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
[ -f "$VAR_SUBSYS_KTUNE" ] || exit 0
|
||||||
|
stop
|
||||||
|
RETVAL=$?
|
||||||
|
;;
|
||||||
|
reload)
|
||||||
|
[ -f "$VAR_SUBSYS_KTUNE" ] && reload
|
||||||
|
RETVAL=$?
|
||||||
|
;;
|
||||||
|
restart|force-reload)
|
||||||
|
[ -f "$VAR_SUBSYS_KTUNE" ] && stop
|
||||||
|
start
|
||||||
|
RETVAL=$?
|
||||||
|
;;
|
||||||
|
condrestart|try-restart)
|
||||||
|
[ -f "$VAR_SUBSYS_KTUNE" ] || exit 0
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
RETVAL=$?
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status
|
||||||
|
RETVAL=$?
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
|
||||||
|
RETVAL=2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
17
tune-profiles/spindown-disk/ktune.sysconfig
Normal file
17
tune-profiles/spindown-disk/ktune.sysconfig
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# ktune service configuration
|
||||||
|
|
||||||
|
# This is the ktune sysctl file. You can comment this out to prevent ktune
|
||||||
|
# from applying its sysctl settings.
|
||||||
|
SYSCTL="/etc/sysctl.ktune"
|
||||||
|
|
||||||
|
# Use *.conf files in the ktune configuration directory /etc/ktune.d.
|
||||||
|
# Value: yes|no, default: yes
|
||||||
|
# It is useful if you want to load settings from additional files. Set this to
|
||||||
|
# no if you to prevent ktune from using these additional files.
|
||||||
|
USE_KTUNE_D="yes"
|
||||||
|
|
||||||
|
# This is the custom sysctl configuration file. Any settings in this file will
|
||||||
|
# be applied after the ktune settings, overriding them. Comment this out to
|
||||||
|
# use only the ktune settings.
|
||||||
|
SYSCTL_POST="/etc/sysctl.conf"
|
||||||
|
|
||||||
7
tune-profiles/spindown-disk/sysctl.ktune
Normal file
7
tune-profiles/spindown-disk/sysctl.ktune
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# ktune sysctl settings
|
||||||
|
|
||||||
|
vm.dirty_writeback_centisecs=6000
|
||||||
|
vm.dirty_expire_centisecs=9000
|
||||||
|
vm.dirty_ratio=60
|
||||||
|
vm.laptop_mode=5
|
||||||
|
vm.swappiness=30
|
||||||
57
tune-profiles/spindown-disk/tuned.conf
Normal file
57
tune-profiles/spindown-disk/tuned.conf
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
#
|
||||||
|
# tuned configuration main service
|
||||||
|
#
|
||||||
|
|
||||||
|
[main]
|
||||||
|
# Interval for monitoring and tuning. Default is 10s.
|
||||||
|
# interval=10
|
||||||
|
|
||||||
|
#
|
||||||
|
# Disk monitoring section
|
||||||
|
#
|
||||||
|
[DiskMonitor]
|
||||||
|
# Enabled or disable the plugin. Default is True. Any other value
|
||||||
|
# disables it.
|
||||||
|
enabled=False
|
||||||
|
|
||||||
|
#
|
||||||
|
# Disk tuning section
|
||||||
|
#
|
||||||
|
[DiskTuning]
|
||||||
|
# Enabled or disable the plugin. Default is True. Any other value
|
||||||
|
# disables it.
|
||||||
|
enabled=False
|
||||||
|
hdparm=False
|
||||||
|
alpm=False
|
||||||
|
|
||||||
|
#
|
||||||
|
# Net monitoring section
|
||||||
|
#
|
||||||
|
[NetMonitor]
|
||||||
|
# Enabled or disable the plugin. Default is True. Any other value
|
||||||
|
# disables it.
|
||||||
|
enabled=False
|
||||||
|
|
||||||
|
#
|
||||||
|
# Net tuning section
|
||||||
|
#
|
||||||
|
[NetTuning]
|
||||||
|
# Enabled or disable the plugin. Default is True. Any other value
|
||||||
|
# disables it.
|
||||||
|
enabled=False
|
||||||
|
|
||||||
|
#
|
||||||
|
# CPU monitoring section
|
||||||
|
#
|
||||||
|
[CPUMonitor]
|
||||||
|
# Enabled or disable the plugin. Default is True. Any other value
|
||||||
|
# disables it.
|
||||||
|
enabled=False
|
||||||
|
|
||||||
|
#
|
||||||
|
# CPU tuning section
|
||||||
|
#
|
||||||
|
[CPUTuning]
|
||||||
|
# Enabled or disable the plugin. Default is True. Any other value
|
||||||
|
# disables it.
|
||||||
|
enabled=False
|
||||||
Loading…
Reference in a new issue