Mainline Kernel on CentOS 7: Difference between revisions
From Leo's Notes
This page was last edited on 30 December 2021, at 02:23.
mNo edit summary |
m Removed LinuxDistros category |
||
| (8 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
The following script was pulled from one of my setup scripts. | The following script was pulled from one of my setup scripts. | ||
{{highlight|lang=bash|code= | |||
function install_new_kernel() { | function install_new_kernel() { | ||
if ! yum repolist | if ! yum repolist {{!}} grep elrepo > /dev/null ; then | ||
echo "This will now install the ELRepo repository from ELRepo.org." | echo "This will now install the ELRepo repository from ELRepo.org." | ||
if ! prompt "Do you wish to install ELRepo on the system?" Y ; then | if ! prompt "Do you wish to install ELRepo on the system?" Y ; then | ||
| Line 24: | Line 24: | ||
# Install the mainline kernel | # Install the mainline kernel | ||
yum install kernel-ml kernel-ml-devel kernel-ml-headers \ | 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 | 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:" | echo "Current kernels installed:" | ||
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg | awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg | ||
echo "-- End of List --" | echo "-- End of List --" | ||
echo "Kernel made to boot will be: " $(awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg | 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 | if prompt "Is this okay?" Y ; then | ||
| Line 46: | Line 46: | ||
install_new_kernel | install_new_kernel | ||
}} | |||
[[Category:Linux]] | {{Navbox Linux}}[[Category:Linux]] | ||
Latest revision as of 02:23, 30 December 2021
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