diff -r 0000000000000000000000000000000000000000 -r 83495d1e1f6ca0b2ff692163a67bf474134259ed ksm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ksm Sat Jul 20 21:50:35 2013 -0500 @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Author: Marin Atanasov Nikolov +# +### BEGIN INIT INFO +# Provides: ksm +# Required-Start: +# Required-Stop: +# X-Start-Before: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Enable and disable KVM KSM +# Description: Enables and disables the KVM Kernel Samepage Merging +# feature of the kernel +### END INIT INFO + +set -e + +. /lib/lsb/init-functions + +do_start() { + echo 1 > /sys/kernel/mm/ksm/run + log_success_msg "Enabling Kernel Samepage Merging" +} + +do_stop() { + echo 0 > /sys/kernel/mm/ksm/run + log_success_msg "Disabling Kernel Samepage Merging" +} + +do_status() { + local ksm_status + ksm_status=$( cat /sys/kernel/mm/ksm/run ) + + if [ ${ksm_status} -eq 1 ]; then + log_success_msg "Kernel Samepage Merging is enabled" + else + log_success_msg "Kernel Samepage Merging is disabled" + fi +} + +case "${1}" in + start) + do_start + ;; + reset|stop) + do_stop + ;; + status) + do_status + ;; + reload|restart|force-reload) + do_stop + do_start + ;; + *) + log_success_msg "usage: ${0} {start|stop|status|reload|restart|force-reload|reset}" >&2 + ;; +esac \ No newline at end of file