Mainline Kernel on CentOS 7: Difference between revisions
From Leo's Notes
This page was last edited on 1 September 2019, at 04:50.
m Text replacement - "Category:Linux " to "Category:Linux{{Navbox Linux}} " |
m Text replacement - "{{Navbox Linux}} {{Navbox Linux}}" to "{{Navbox Linux}}" |
||
| Line 49: | Line 49: | ||
[[Category:Linux]]{{Navbox Linux}} | [[Category:Linux]]{{Navbox Linux}} | ||
Revision as of 04:50, 1 September 2019
The following script will install the mainline kernel from ElRepo. The mainline kernel will be the most recent stable kernel rather than the more conservative kernel used in CentOS.
The following script was pulled from one of my setup scripts.
function install_new_kernel() {
if ! yum repolist | grep elrepo > /dev/null ; then
echo "This will now install the ELRepo repository from ELRepo.org."
if ! prompt "Do you wish to install ELRepo on the system?" Y ; then
return
fi
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum clean all
fi
# Need to enable the repo.
sed -i '/\[elrepo-kernel\]/,/^\[/ s/enabled=0/enabled=1/' /etc/yum.repos.d/elrepo.repo
# Should do a full update first.
yum update
# Install the mainline kernel
yum install kernel-ml kernel-ml-devel kernel-ml-headers \
|| die "Could not install kernel."
Option=`awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg | /bin/grep -n 3.17 | head -n 1 | cut -f1 -d:`
echo "Current kernels installed:"
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
echo "-- End of List --"
echo "Kernel made to boot will be: " $(awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg | sed -n "$Option{p;q}")
if prompt "Is this okay?" Y ; then
grub2-set-default $[$Option - 1]
grub2-mkconfig -o /boot/grub2/grub.cfg
echo "Default now set to: " $(grub2-editenv list)
warning "You should now reboot the server to apply the new kernel."
else
echo "Please select the grub option and run:"
echo " grub2-set-default X - where X is the option"
echo " grub2-mkconfig -o /boot/grub2/grub.cfg"
fi
}
install_new_kernel