enieto87

Kernel Upgrade in 3 Steps for CentOS 7

Sep 27th, 2021 (edited)
1,203
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### Kernel Long Term Version Install for CentOS 7
  2. ### At the end of the script, you can test with "uname -sr" Will quit, and reboot alone 2 times more. Be patient.
  3. ### By ENL & ESJ Forever and Ever.
  4. ### You may have to wait, 10 min...
  5. ### In a new installation. Create on /root the 3 following files, chmod +x the 3. and just run once "kernel1.sh":
  6. ### Start of kernel1.sh
  7. #!/bin/bash
  8. line="@reboot ( sleep 90 ; sh ~/kernel2.sh )"
  9. (crontab -u root -l; echo "$line" ) | crontab -u root -
  10. sudo yum -y update && sudo yum -y install yum-plugin-fastestmirror
  11. sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org && sudo rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
  12. sudo yum --enablerepo=elrepo-kernel install kernel-lt -y
  13. sudo rpm -q kernel-tools | xargs -I{} sudo yum remove -y {} && sudo rpm -q kernel-tools-libs | xargs -I{} sudo yum remove -y {}
  14. sudo yum --enablerepo=elrepo-kernel install kernel-lt-devel kernel-lt-headers kernel-lt-tools -y
  15. sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg && sudo grub2-set-default 0 && sudo grub2-mkconfig -o /boot/grub2/grub.cfg
  16. service crond reload
  17. sudo reboot
  18. ### End of Paste (Don't paste this line)
  19. ### Start of kernel2.sh
  20. #!/bin/bash
  21. line="@reboot ( sleep 90 ; sh ~/kernel3.sh )"
  22. sed -i '$ d' /var/spool/cron/root
  23. (crontab -u root -l; echo "$line" ) | crontab -u root -
  24. sudo yum install yum-utils -y
  25. sudo package-cleanup --oldkernels --count=1 -y
  26. sudo reboot
  27. ### End of Paste (Don't paste this line)
  28. ### Start of kernel3.sh
  29. #!/bin/bash
  30. sed -i '$ d' /var/spool/cron/root
  31. sudo rpm -q kernel | xargs -I{} sudo yum remove -y {}
  32. sudo reboot
  33. ### End of Paste (Don't paste this line)
RAW Paste Data