From c2486397a9cbee7ff2bdffeadacd7cd13a78299a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcela=20Ma=C5=A1l=C3=A1=C5=88ov=C3=A1?= Date: Wed, 9 Sep 2009 13:20:26 +0200 Subject: [PATCH] =?UTF-8?q?Spindown=20disc=20profile=20-=20set=20disc=20to?= =?UTF-8?q?=20minimum=20spins.=20Writen-by:=20Daniel=20Mach=20Rewrite-into?= =?UTF-8?q?-profile:=20Marcela=20Ma=C5=A1l=C3=A1=C5=88ov=C3=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tune-profiles/spindown-disk/README | 14 ++ tune-profiles/spindown-disk/ktune.sh | 143 ++++++++++++++++++++ tune-profiles/spindown-disk/ktune.sysconfig | 17 +++ tune-profiles/spindown-disk/sysctl.ktune | 7 + tune-profiles/spindown-disk/tuned.conf | 57 ++++++++ 5 files changed, 238 insertions(+) create mode 100644 tune-profiles/spindown-disk/README create mode 100755 tune-profiles/spindown-disk/ktune.sh create mode 100644 tune-profiles/spindown-disk/ktune.sysconfig create mode 100644 tune-profiles/spindown-disk/sysctl.ktune create mode 100644 tune-profiles/spindown-disk/tuned.conf diff --git a/tune-profiles/spindown-disk/README b/tune-profiles/spindown-disk/README new file mode 100644 index 0000000..050724d --- /dev/null +++ b/tune-profiles/spindown-disk/README @@ -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. + diff --git a/tune-profiles/spindown-disk/ktune.sh b/tune-profiles/spindown-disk/ktune.sh new file mode 100755 index 0000000..ca923a6 --- /dev/null +++ b/tune-profiles/spindown-disk/ktune.sh @@ -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 diff --git a/tune-profiles/spindown-disk/ktune.sysconfig b/tune-profiles/spindown-disk/ktune.sysconfig new file mode 100644 index 0000000..6ac5f42 --- /dev/null +++ b/tune-profiles/spindown-disk/ktune.sysconfig @@ -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" + diff --git a/tune-profiles/spindown-disk/sysctl.ktune b/tune-profiles/spindown-disk/sysctl.ktune new file mode 100644 index 0000000..509b7c3 --- /dev/null +++ b/tune-profiles/spindown-disk/sysctl.ktune @@ -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 diff --git a/tune-profiles/spindown-disk/tuned.conf b/tune-profiles/spindown-disk/tuned.conf new file mode 100644 index 0000000..0f925cf --- /dev/null +++ b/tune-profiles/spindown-disk/tuned.conf @@ -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