-
-
Save 5car1z/eabdecb2fe3829138918ae308a2be41b to your computer and use it in GitHub Desktop.
init.d script for KVM KSM on Debian GNU/Linux -- https://github.com/dnaeon/ksm-init.d-debian | https://dnaeon.github.io/enable-ksm-during-boot-time-on-linux/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Author: Marin Atanasov Nikolov <[email protected]> | |
# | |
### 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.