One would expect that yum’s reinstall command would do the trick, but alas – it does not.
# yum reinstall kernel Package kernel-2.6.18-194.32.1.el5.x86_64 is allowed multiple installs, skipping Package kernel-2.6.18-274.12.1.el5.x86_64 is allowed multiple installs, skipping Package kernel-2.6.18-194.el5.x86_64 is allowed multiple installs, skipping Package kernel-2.6.18-308.1.1.el5.x86_64 is allowed multiple installs, skipping Package kernel-2.6.18-308.11.1.el5.x86_64 is allowed multiple installs, skipping Nothing to do
To reinstall the kernel, you actually have to remove it first and then install it again. You can remove your currently running kernel since it’s operating completely from memory and does not rely on the physical files at the moment you’re trying to reinstall it. So, first find out your current version.
# uname -r 2.6.18-308.11.1.el5
List the installed kernels
See what other kernels you may have installed.
# rpm -qa | grep kernel | sort kernel-2.6.18-194.32.1.el5 kernel-2.6.18-194.el5 kernel-2.6.18-274.12.1.el5 kernel-2.6.18-308.1.1.el5 kernel-2.6.18-308.11.1.el5 kernel-headers-2.6.18-308.1.1.el5
Remove obsolete kernels
If you don’t need the older kernels, you can safely remove them. You should keep at least one extra, just in case this reinstall fails (or if the new kernel is giving you problems).
# yum remove kernel-2.6.18-194.32.1.el5 kernel-2.6.18-194.el5
Reinstall the Linux Kernel via RPM/Yum
Now, to reinstall the kernel you want, first remove it by specifying the exact version (usually the currently running kernel, see uname -r above).
# yum remove kernel-2.6.18-308.11.1.el5 ===================================================================== Package Arch Version Repository Size ===================================================================== Removing: kernel x86_64 2.6.18-308.11.1.el5 installed 98 M Transaction Summary ===================================================================== Remove 1 Package(s) Reinstall 0 Package(s) Downgrade 0 Package(s) Is this ok [y/N]: y
Confirm that the kernel is actually removed.
# rpm -qa | grep kernel | sort -n kernel-2.6.18-308.1.1.el5 kernel-headers-2.6.18-308.11.1.el5
It’s not showing up (only the older kernel), so reinstall it.
# yum install kernel-2.6.18-308.11.1.el5 ======================================================================= Package Arch Version Repository Size ======================================================================= Installing: kernel x86_64 2.6.18-308.11.1.el5 updates 21 M Transaction Summary ======================================================================= Install 1 Package(s) Upgrade 0 Package(s) Total download size: 21 M Is this ok [y/N]: y
Verify the new Linux Kernel is installed
And you should see the Kernel appear again.
# rpm -qa | grep kernel | sort -n kernel-2.6.18-308.11.1.el5 kernel-2.6.18-308.1.1.el5 kernel-headers-2.6.18-308.11.1.el5
After that, reboot the server again to make sure everything went as expected and you should have a cleanly reinstalled Linux Kernel available to you (for whatever reason this may have been necessary).