Add bootscript to tune disk parameters
authorHugo Villeneuve <hugo@hugovil.com>
Thu, 19 Sep 2013 01:38:35 +0000 (21:38 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Thu, 31 Jul 2014 02:15:25 +0000 (22:15 -0400)
stage1/bootscripts/tune [new file with mode: 0755]
stage1/install-bootscripts

diff --git a/stage1/bootscripts/tune b/stage1/bootscripts/tune
new file mode 100755 (executable)
index 0000000..ac578dc
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+# tune
+# Tune kernel parameters for hardware
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+tune_disks()
+{
+    cd /sys/block
+
+    for disk in * ; do
+        if cat /sys/block/${disk}/queue/rotational | grep -q 1 ; then
+            echo "cfq" > /sys/block/${disk}/queue/scheduler
+        else
+            # SSD
+            echo "deadline" > /sys/block/${disk}/queue/scheduler
+        fi
+
+        echo -n "Scheduler for disk ${disk} = "
+        cat /sys/block/${disk}/queue/scheduler | sed "s/.*\[\(.*\)\].*/\1/"
+    done
+}
+
+case "${1}" in
+    start)
+       cmd_run_log_box "Tuning disk parameters" tune_disks
+        ;;
+    *)
+        echo "Usage: $0 {start}"
+        exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+exit $?
index 15f22e8..5b03164 100755 (executable)
@@ -31,6 +31,7 @@ done
 bootscript_add_rcsysinit initlog     05 00
 bootscript_add_rcsysinit hostname    10 00
 bootscript_add_rcsysinit mountkernfs 15 00
+bootscript_add_rcsysinit tune        17 00
 bootscript_add_rcsysinit modules     20 00
 bootscript_add_rcsysinit udev        25 00
 bootscript_add_rcsysinit checkfs     30 00