HowTo: Prevent Yum From Upgrading The Kernel On a CentOS / Red Hat Enterprise Linux

by on February 19, 2014 · 6 comments· LAST UPDATED February 19, 2014

in , ,

I am a new RHEL / Centos Linux server admin. I would like yum to update all packages except the Linux Kernel. How can I prevent yum command from updating kernel on a CentOS/RHEL/Fedora Linux based systems?

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNone
Estimated completion time2m
You can prevent yum command from updating the Kernel permanently by following the simple steps.

Option #1: Edit /etc/yum.conf file

Use a text editor such as vi to edit /etc/yum.conf:
# vi /etc/yum.conf

Append/modify exclude directive line under [main] section, enter:
exclude=kernel*
Save and close the file. Try, updating the system without updating the Linux kernel:
# yum -y update
This is a permanent option, so you don't need pass the -x option to yum command.

Option #2: Pass the -x option to prevent yum from updating kernel

The syntax is as follows to skip update on command line itself:
# yum -x 'kernel*' update

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 6 comments… read them below or add one }

1 benjamin February 19, 2014 at 9:30 am

The title is misleading.Should be more like
How to prevent Yum from Upgrading the kernel on a CentOS / Red Hat Enterprise Linux

Reply

2 Nix Craft February 19, 2014 at 10:21 am

Done. I appreciate your feedback and post :)

Reply

3 benjamin February 19, 2014 at 10:29 am

Welcome :)

Reply

4 Nikhil February 21, 2014 at 5:13 am

Cool stuff :)

Reply

5 Riot77 February 24, 2014 at 10:50 am

Appreciated alot! This solved my problem with virtual machine wanting to upgrade kernel (and by that also uninstall bunch of VM addons… => crashing my system). Now I keep my kernel at stable version without having issues with upgrades. I can upgrade everything else.

Reply

6 Franklyn Mendez March 3, 2014 at 2:14 pm

Hello,
Thanks for the article,
I would also add to the /etc/yum.conf exclude statement redhat-release* for Red Hat Linux servers in the event you don’t want it to move up your release.
exclude=kernel* redhat-release*

Sometimes we don’t want to patch kernel as well as your current Red Hat version. Also there might be some application requirements that will force you to stick to a certain version of the OS.

Reply

Leave a Comment

Tagged as: , , , ,

Previous Faq:

Next Faq: