Skip to content

Instantly share code, notes, and snippets.

@sempr
Last active February 3, 2021 09:52
Show Gist options
  • Save sempr/7109d7bafa6a956e0db89261e8ae50d7 to your computer and use it in GitHub Desktop.
Save sempr/7109d7bafa6a956e0db89261e8ae50d7 to your computer and use it in GitHub Desktop.
使用kexec来替换新内核
latestkernel=`ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | head -n1`
echo $latestkernel
kexec -l /boot/vmlinuz-${latestkernel} --initrd=/boot/initramfs-${latestkernel}.img --append="`cat /proc/cmdline`"
kexec -e
# 备注,其实和重启没啥两样, uptime也会清零重算,唯一的好处就是比重启要快一点点
# remove old kernels on centos 8
dnf remove --oldinstallonly --setopt installonly_limit=1 kernel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment