Wednesday, December 26, 2018

RHEL - Remove old Kernals on RHEL based systems

Remove old Kernals on RHEL based systems
===================================

1. Check current version of installed Kernel
[root@sam ~]# uname -a
Linux sam.expanor.local 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

2. List all installed Kernels on your system

[root@sam ~]# rpm -q kernel
kernel-3.10.0-229.el7.x86_64
kernel-3.10.0-327.el7.x86_64


3. Remove old kernel packages
- You need to install cleanup package tool which in part of yum-utils package.

[root@sam ~]# yum search yum-utils
[root@sam ~]# yum install yum-utils
Package yum-utils-1.1.31-34.el7.noarch already installed and latest version
Nothing to do

[root@sam ~]# package-cleanup --help | grep old
    usage: package-cleanup --problems or --leaves or --orphans or --oldkernels
    --oldkernels        -> Remove old kernel and kernel-devel packages
[root@sam ~]# package-cleanup --help | grep count
    --count=KERNELCOUNT -> Number of kernel packages to keep on the system (default 2)

# package-cleanup -–oldkernels -–count=1

4. Now review the remaining kernels on your system

[root@sam ~]# rpm -q kernel
kernel-3.10.0-229.el7.x86_64
kernel-3.10.0-327.el7.x86_64

5. Automatically remove old kernels
Edit a file /etc/yum.conf and check the value for installonly_limit=. Change the vlue to the one you like. Just keep minimum of 2 version so set 2 or more number.

No comments:

Post a Comment