更新内核到 v6.2.1

  1. bash -c "$(curl -sSL https://bd-rce.coding.net/api/user/bd-rce/project/shell/shared-depot/lts-tools-v10/git/blob/master/kernel/v6.2.1-t2023022801/install.sh | jq -r '.data.file.data')"
  1. #!/usr/bin/env bash
  2. __main() {
  3. #导入公钥
  4. rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
  5. #添加YUM源
  6. yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
  7. # 查看最新内核版本
  8. # kernel-lt 长期支持版
  9. # kernel-ml 主线最新版本
  10. # yum --disablerepo="*" --enablerepo=elrepo-kernel list kernel*
  11. # 本文主要安装主线最新版
  12. _branch="ml"
  13. _version="" # 不填版本则是最新版
  14. yum install -y --disablerepo="*" --enablerepo="elrepo-kernel" \
  15. "kernel-${_branch}${_version}" \
  16. "kernel-${_branch}-devel$_version" \
  17. "kernel-${_branch}-headers$_version" \
  18. "kernel-${_branch}-tools$_version" \
  19. "kernel-${_branch}-tools-libs$_version" \
  20. "kernel-${_branch}-tools-libs-devel$_version" \
  21. --skip-broken
  22. cat >/etc/default/grub <<'EOF'
  23. GRUB_DEFAULT="saved"
  24. GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
  25. GRUB_DISABLE_SUBMENU="true"
  26. GRUB_DISABLE_RECOVERY="true"
  27. GRUB_TIMEOUT="3"
  28. GRUB_TERMINAL="console serial"
  29. GRUB_TERMINAL_OUTPUT="console"
  30. GRUB_CMDLINE_LINUX="intel_iommu=ats intel_iommu=unsafe_interrupts intel_iommu=on iommu=pt crashkernel=auto rhgb quiet"
  31. GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,115200"
  32. GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
  33. EOF
  34. grub2-set-default 0 #设置新内核为默认启动项,默认情况下新内核序号为0
  35. grub2-mkconfig -o /boot/grub2/grub.cfg 2>/dev/null
  36. grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg 2>/dev/null
  37. # 开机免密码
  38. sed -i 's,^ExecStart=.*$,ExecStart=-/sbin/agetty --autologin root --noclear %I,' /usr/lib/systemd/system/serial-getty@.service
  39. sed -i 's,^ExecStart=.*$,ExecStart=-/sbin/agetty --autologin root --noclear %I,' /usr/lib/systemd/system/getty@.service
  40. systemctl enable serial-getty@ttyS0.service
  41. }
  42. __main

内核参数设置

  1. bash -c "$(curl -sSL https://bd-rce.coding.net/api/user/bd-rce/project/shell/shared-depot/lts-tools-v10/git/blob/master/kernel/v6.2.1-t2023022801/sysctl_conf.sh | jq -r '.data.file.data')"

推荐阅读

CentOS 7 内核更新
CentOS 7升级内核简要说明_ITPUB博客
centos7 升级内核版本
升级 centos7 内核_若云_bai的博客-CSDN博客