如何将CentOS 6内核升级至最新版本?升级后重启仍无法使用最新内核
Hey there, let's tackle this CentOS 6 kernel upgrade issue where the system isn't booting into the new kernel after restart. I've seen this pop up a lot, so let's break it down step by step.
First, let's verify that the new kernel was actually installed successfully, and check which kernel your system is currently using:
- List all installed kernels with:
rpm -qa | grep kernel - Check the currently running kernel:
uname -r
Compare the output—you should see the newer kernel version in the installed list, but it won't match the running one if the issue persists.
CentOS 6 relies on GRUB Legacy, and its config file lives at /boot/grub/grub.conf. This file controls which kernel the system boots into by default.
- View the config with:
cat /boot/grub/grub.conf
Look for two key parts:
- The
defaultline (e.g.,default=0)—this is the index of the boot entry GRUB uses (count starts at 0). - The
titleentries below—each corresponds to a kernel version. Find the title line for your new, upgraded kernel.
For example, if your new kernel is the second title entry in the list, its index is 1. If the default value is set to 0 (the old kernel), that's exactly why your system isn't booting into the new one.
Now let's update the GRUB config to prioritize the new kernel:
- Open the config file with a text editor (like vi):
vi /boot/grub/grub.conf - Find the
defaultline and change its value to the index of your new kernel's title entry. - Save and exit the editor (in vi, type
:wqand press Enter).
Alternatively, you can use the grub-set-default command to set the index directly, like:
grub-set-default 1
Just replace 1 with the correct index for your new kernel.
Double-check that the default value is correct by re-running cat /boot/grub/grub.conf, then reboot your system:
reboot
Once it's back up, run uname -r again—you should see the new kernel version listed now.
Troubleshooting note
If this still doesn't work, it's possible the new kernel's initramfs wasn't generated properly during installation. You can regenerate it manually with:
mkinitrd -f /boot/initramfs-<new-kernel-version>.img <new-kernel-version>
Replace <new-kernel-version> with the full version string of your upgraded kernel (from the rpm -qa output), then repeat the GRUB config check and reboot.
内容的提问来源于stack exchange,提问作者Chloe

