≡ Menu

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

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?

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:
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

{ 6 comments… add one }

  • benjamin February 19, 2014, 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

    • Nix Craft February 19, 2014, 10:21 am

      Done. I appreciate your feedback and post :)

  • benjamin February 19, 2014, 10:29 am

    Welcome :)

  • Nikhil February 21, 2014, 5:13 am

    Cool stuff :)

  • Riot77 February 24, 2014, 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.

  • Franklyn Mendez March 3, 2014, 2:14 pm

    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.

Leave a Comment

   Tagged with: , , , ,