Skip to content

Instantly share code, notes, and snippets.

@bouroo
Last active Aug 11, 2020
Embed
What would you like to do?
Update CentOS mainline stable kernel for deploy Google BBR
#!/usr/bin/env bash
if [ "$(whoami)" != "root" ]; then
SUDO=sudo
fi
if ! $(type lsb_release > /dev/null 2>&1) ; then
${SUDO} yum install -y redhat-lsb-core
fi
majversion=$(lsb_release -rs | cut -f1 -d.)
# Import the ELRepo GPG Key
${SUDO} rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
${SUDO} yum insall -y yum-plugin-fastestmirror
# Install latest kernel using the ELRepo repository:
if [ ${majversion} == 6 ]; then
# CentOS 6
${SUDO} yum install -y https://www.elrepo.org/elrepo-release-6-9.el6.elrepo.noarch.rpm
${SUDO} yum --enablerepo=elrepo-kernel install -y kernel-lt kernel-lt-devel
elif [ ${majversion} == 7 ]; then
# CentOS 7
${SUDO} yum install -y https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
${SUDO} yum --enablerepo=elrepo-kernel install -y kernel-ml kernel-ml-devel
elif [ ${majversion} == 8 ]; then
# CentOS 8
${SUDO} yum install -y https://www.elrepo.org/elrepo-release-8.0-2.el8.elrepo.noarch.rpm
${SUDO} yum --enablerepo=elrepo-kernel install -y kernel-ml kernel-ml-devel
else
echo "Not support version"
exit 1
fi
# Check all entries in the grub2 menu
if [ ${majversion} == 6 ]; then
${SUDO} egrep ^menuentry /etc/grub.conf | cut -f 2 -d \'
# Set the default boot entry
${SUDO} sed -i "s/default=[0-9]/default=0/g" /etc/grub.conf
else
${SUDO} egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
# Set the default boot entry
${SUDO} grub2-set-default 0
fi
# Set BBR TCP congestion control
# Or use zercle's sysctl script
# https://gist.github.com/bouroo/bc52ad58a6e75d44e5235b229e9ca988
echo '# Fallback if BBR not support' | ${SUDO} tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=cubic' | ${SUDO} tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' | ${SUDO} tee -a /etc/sysctl.conf
echo 'net.core.default_qdisc=fq' | ${SUDO} tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_notsent_lowat = 16384' | ${SUDO} tee -a /etc/sysctl.conf
${SUDO} sysctl -p
# After reboot check kernel and remove normal kernel
# uname -a
# if using kernel-ml
# yum remove kernel
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment