• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to delete unused kernels and keep only the running kernel in CentOS/RHEL

by admin

Question: How to keep only running kernel in a CentOS/RHEL Linux system?

Keeping less than 2 kernels in a Linux system is strongly not recommended. There are several reasons for this recommendation:

  • If an installation of a new kernel is interrupted or aborted in any before it completes successfully, rebooting the system with that kernel may not be possible. If there is another kernel installed, it will allow booting the system to attempt a re-installation of the non-booting kernel.
  • If abnormal behavior is seen with a specific kernel, there is the option of booting the system with another one from the same family to check if the behavior is reproducible.
  • If abnormal behavior is seen with a kernel from a particular kernel family (UEK or RHCK), there is the option of booting with a kernel from the other family to check if the same behavior is reproducible.

Currently, the default in Oracle Linux is to keep the 3 last kernels of each family. This is considered a best practice. The installonly_limit parameter in /etc/yum.conf is set to 3 for the above behavior and can be changed to 2 to keep at most 2 kernels from each family.

It is not possible to set the parameter to ‘1’ and doing so will produce an error. This is because when installing a new kernel, the existing running kernel cannot be uninstalled as it is in use by the system. This means that the strict minimum is actually 2 kernels of each family.

Given the above, a non-running kernel can be manually removed via yum as the root user:

# yum remove kernel-xxx
NOTE: Never remove the running kernel from a Linux system! This will remove kernel bits from the system, with the potential to not even allow a reinstall of a kernel again (unless another one was kept in the system to allow booting from to recover).

Filed Under: CentOS/RHEL, Linux

Some more articles you might also be interested in …

  1. chage: command not found
  2. How to use “btrfs scrub” command to manage scrubbing on Btrfs file systems
  3. /var/cache/yum Constantly Filling Files System in CentOS/RHEL
  4. “Couldn’t authenticate with keytab while discovering which salt to use: hostname: KDC has no support for encryption type” – error while joining domain
  5. locate: command not found
  6. Configure Persistent NIC Names of Network Adaptors in CentOS/RHEL using udev Rules
  7. caja: command not found
  8. mdbook Command Examples in Linux
  9. “error: can’t find command ‘ffffffffff…..” GRUB2 error CentOS/RHEL 7
  10. module: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • raw: command not found
  • raw Command Examples in Linux
  • rankmirrors Command Examples in Linux
  • radeontop: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright