0% found this document useful (0 votes)
3 views1 page

Disable Transparent Huge Pages Script

This Bash script is an init script designed to disable transparent huge pages (THP) on system boot to enhance Couchbase performance. It checks for the appropriate directory for THP settings and modifies the configuration to prevent THP from being enabled. The script is set to run at specific run levels and before the Couchbase server starts.

Uploaded by

5yhsgkgrzb
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Disable Transparent Huge Pages Script

This Bash script is an init script designed to disable transparent huge pages (THP) on system boot to enhance Couchbase performance. It checks for the appropriate directory for THP settings and modifies the configuration to prevent THP from being enabled. The script is set to run at specific run levels and before the Couchbase server starts.

Uploaded by

5yhsgkgrzb
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#!

/bin/bash
### BEGIN INIT INFO
# Provides: disable-thp
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: couchbase-server
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable THP
# Description: Disables transparent huge pages (THP) on boot, to improve
# Couchbase performance.
### END INIT INFO

case $1 in
start)
if [ -d /sys/kernel/mm/transparent_hugepage ]; then
thp_path=/sys/kernel/mm/transparent_hugepage
elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
thp_path=/sys/kernel/mm/redhat_transparent_hugepage
else
return 0
fi

echo 'never' > ${thp_path}/enabled


echo 'never' > ${thp_path}/defrag

re='^[0-1]+$'
if [[ $(cat ${thp_path}/khugepaged/defrag) =~ $re ]]
then
# RHEL 7
echo 0 > ${thp_path}/khugepaged/defrag
else
# RHEL 6
echo 'no' > ${thp_path}/khugepaged/defrag
fi

unset re
unset thp_path
;;
esac

You might also like