LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why cann't I remove old kernels? (https://www.linuxquestions.org/questions/linux-newbie-8/why-cannt-i-remove-old-kernels-4175657059/)

Prze-moC 07-08-2019 12:33 PM

Why cann't I remove old kernels?
 
Hi,
I'm new to all this, so let me post a bit of background before asking my questions (on the very bottom).

I had recently updated the kernel (using "yum update"):
Code:

[root@plsekatlastst01 firmware]# uname -a
Linux plsekatlastst01 4.1.12-124.28.1.el7uek.x86_64 #2 SMP Mon Jun 3 14:09:53 PDT 2019 x86_64 x86_64 x86_64 GNU/Linux

Now, I want to remove the old kernels to avoid /boot overfill.
Code:

[root@plsekatlastst01 firmware]#  ls -lah /boot/vmlinuz*
-rwxr-xr-x. 1 root root 4.5M Apr 22  2016 /boot/vmlinuz-0-rescue-2034cfa2044148d6b61b951f04bb3284
-rwxr-xr-x. 1 root root 6.4M Jun  4 20:33 /boot/vmlinuz-3.10.0-957.21.2.el7.x86_64
-rwxr-xr-x. 1 root root 6.4M Jun 18 00:54 /boot/vmlinuz-3.10.0-957.21.3.el7.x86_64
-rwxr-xr-x. 1 root root 6.2M Jun  3 23:14 /boot/vmlinuz-4.1.12-124.28.1.el7uek.x86_64
-rwxr-xr-x. 1 root root 6.2M Jun 11 09:48 /boot/vmlinuz-4.1.12-124.28.3.el7uek.x86_64
-rwxr-xr-x. 1 root root 6.2M Jun 20 21:05 /boot/vmlinuz-4.1.12-124.28.5.el7uek.x86_64

Found instructions here: https://www.2daygeek.com/remove-dele...s-fedora-rhel/ and followed, but when I run
Code:

package-cleanup --oldkernels --count=1
... it only wants to clean 3.10.0-957.21.2.el7.
What about the old 4.1.12 ones?
I also run this:
Code:

[root@plsekatlastst01 firmware]# rpm -q kernel
kernel-3.10.0-957.21.3.el7.x86_64
kernel-3.10.0-957.21.2.el7.x86_64

QUESTION 1:
How to clean-up old kernels?

QUESTION 2:
Would you know why "rpm -q kernel" shows only 3.10 entries while /boot folder contains 6 vmlinuz* files?

QUESTION 3:
Do I need to fix anything so "rpm -q kernel" shows all kernels?

MensaWater 07-08-2019 01:20 PM

"rpm -q kernel" shows what Redhat Package Manager (RPM) packages were installed named "kernel". What you see after kernel is version and architecture information. If the command only shows the two 3.x kernels it would indicate the other kernel directories you see were NOT installed with rpm.

You could run "rpm -qa |grep kernel" to see if there are other kernel rpms installed.

For any file you see you can run "rpm -qf <pathto/file>" to see what rpm installed it. For example in my /boot I have:
-rwxr-xr-x. 1 root root 5027872 Jul 22 2015 vmlinuz-3.10.0-229.11.1.el7.x86_64
-rwxr-xr-x. 1 root root 5027648 Aug 25 2015 vmlinuz-3.10.0-229.14.1.el7.x86_64
-rwxr-xr-x. 1 root root 5152928 Nov 20 2015 vmlinuz-3.10.0-327.3.1.el7.x86_64
Running the command on each of those with outputs shown:
#rpm -qf /boot/vmlinuz-3.10.0-229.11.1.el7.x86_64
kernel-3.10.0-229.11.1.el7.x86_64

# rpm -qf vmlinuz-3.10.0-229.14.1.el7.x86_64
kernel-3.10.0-229.14.1.el7.x86_64

# rpm -qf vmlinuz-3.10.0-327.3.1.el7.x86_64
kernel-3.10.0-327.3.1.el7.x86_64


It is possible to install software by installing from a tar file, configuring and making files from source or simply by copying in binaries. None of those methods will add it to the rpm database. Since RHEL7 is based on 3.x kernel I think someone was trying to install 4.x kernels manually. My guess is rpm -qf won't show you anything on the three 4.x kernels you list.

The main point in the cleanup tool is to modify your grub configuration. If someone manually installed those 4.x kernels it is possible they also manually edited the grub configuration. You'd want to undo that but you're showing you actually booted from a 4.x kernel.

dc.901 07-08-2019 01:29 PM

You can change the limit in /etc/yum.conf

Update this line: installonly_limit=5

Default is 5 (in CentOS 7.x). I've set my machine to 3...

-----

Did you upgrade from RH 7 to 8 (or CentOS 7 to 8)?

MensaWater 07-08-2019 03:51 PM

el7 suggests RHEL7 (or a derivative like CentOS7). The el7uek is suggestive. When I looked that up I found it is kernels provided by OEL (Oracle Unbreakable Linux). Either the OP has OEL or he has installed kernels built by Oracle on his RHEL7 or CentOS7 system. I haven't looked in a while but I know Oracle did provide their kernel "enhancements" for use on RHEL or CentOS. I never used their kernels on RHEL because Oracle wouldn't support it if it wasn't a full OEL install and RedHat wouldn't support it if it was a RHEL install but used a foreign kernel from Oracle.

I found other posts earlier indicating Fedora's EPEL had 4.x kernels for RHEL7/CentOS7 but RedHat doesn't support those on RHEL7. Since RHEL8 is in general release if the OP is using RHEL7 he might want to upgrade to RHEL8 to get the 4.x kernels that are officially supported by RedHat. If he is on OEL it seems he'd be able to contact Oracle support. Since CentOS7 is not a supported product one can put whatever they want on it. I don't think CentOS8 is available yet.

However, if they got them from OEL or RHEL they didn't use rpm (or yum) to install them (unless the name is more than just "kernel" followed by the dash, version and architecture - doing the rpm with grep I suggested might be informative).

What do "cat /etc/issue" and "cat /etc/redhat-release" show on the server? The output might help to determine the actual distro in use.

Prze-moC 07-09-2019 03:54 AM

I used "yum update" to have all upgraded (incl. kernel).
Indeed rpm sees others just the prefix is little longer:
Code:

[root@plsekatlastst01 boot]# rpm -qa | grep kernel
kernel-uek-4.1.12-124.28.5.el7uek.x86_64
kernel-3.10.0-957.21.2.el7.x86_64
kernel-uek-firmware-4.1.12-124.28.1.el7uek.noarch
kernel-uek-firmware-4.1.12-124.28.3.el7uek.noarch
kernel-uek-4.1.12-124.28.3.el7uek.x86_64
kernel-uek-firmware-4.1.12-124.28.5.el7uek.noarch
kernel-tools-3.10.0-957.21.3.el7.x86_64
kernel-3.10.0-957.21.3.el7.x86_64
kernel-tools-libs-3.10.0-957.21.3.el7.x86_64
kernel-uek-4.1.12-124.28.1.el7uek.x86_64
kernel-headers-3.10.0-957.21.3.el7.x86_64

The other outputs you asked are:
Code:

[root@plsekatlastst01 boot]# cat /etc/issue
\S
Kernel \r on an \m

[root@plsekatlastst01 boot]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)

Sorry, but I do not understand your statements about RHEL7 and RHEL8. How do those answer my questions?

dc.901 07-09-2019 06:22 AM

I have RHEL 7.6 machines but none are showing 4.x kernels (even when I try to do yum update).

I am thinking you have a repo that has those kernels or someone downloaded from here maybe?

Can you also share your repos?
And, what is output of these commands:

Code:

yum repolist
grep installonly_limit /etc/yum.conf


Prze-moC 07-09-2019 07:55 AM

[przemek@plsekatlastst01 ~]$ yum repolist
Loaded plugins: ulninfo
repo id repo name status
ol7_UEKR4/x86_64 Latest Unbreakable Enterprise Kernel Release 4 for Orac 96
ol7_latest/x86_64 Oracle Linux 7Server Latest (x86_64) 13,168
repolist: 13,264
[przemek@plsekatlastst01 ~]$ grep installonly_limit /etc/yum.conf
installonly_limit=2

MensaWater 07-09-2019 07:59 AM

Your output confirms you're using RHEL7.6 (as opposed to OEL or CentOS) assuming no one manually edited the files.

Your earlier uname output shows you're running the kernel provided by:
kernel-uek-firmware-4.1.12-124.28.1.el7uek.noarch

BE SURE YOU HAVE A GOOD BACKUP BEFORE DOING ANYTHING ELSE.

You can likely remove 2 of the other 4.x kernels, since they aren't in use, and associated packages by running:
Code:

yum remove kernel-uek-4.1.12-124.28.5.el7uek.x86_64 kernel-uek-firmware-4.1.12-124.28.3.el7uek.noarch kernel-uek-4.1.12-124.28.3.el7uek.x86_64 kernel-uek-firmware-4.1.12-124.28.5.el7uek.noarch
kernel-tools-libs-3.10.0-957.21.3.el7.x86_64

Since you're running the 4.x kernel (version 4.1.12-124.28.1) you could probably remove the other 2 of the 3.x kernels with yum remove as well. It appears the cleanup tool only works for the kernel packages (3.x in this case) provided by RedHat and doesn't recognize those 4.x kernels possibly because of the uek in the names.

Quote:

Sorry, but I do not understand your statements about RHEL7 and RHEL8. How do those answer my questions?
They don't - I was musing on whether having foreign 4.x kernels on RHEL7 was a good idea. It essentially means RedHat won't support you. Since we don't know why you have those kernels we can't tell if you need them.

As mentioned earlier, though, RedHat doesn't support 4.x kernels on RHEL7. Are you running Oracle products on this server that require a 4.x kernel? You might want to consider moving on to RHEL8 so you have a supported platform (or even OEL7 if that uses 4.x kernel). If you're willing to give up support you might want to move to CentOS7 and add the 4.x kernel to save money on subscriptions.

MensaWater 07-09-2019 08:02 AM

Quote:

Originally Posted by dc.901 (Post 6013356)
I have RHEL 7.6 machines but none are showing 4.x kernels (even when I try to do yum update).

As I noted yesterday. there is no official support for 4.x kernels in RHEL7 so one wouldn't have them on RHEL7 unless they came from somewhere else (e.g. Fedora EPEL or Oracle's site). My read yesterday only mentioned uek in relation to Oracle.

dc.901 07-09-2019 10:00 AM

Quote:

Originally Posted by MensaWater (Post 6013389)
As I noted yesterday. there is no official support for 4.x kernels in RHEL7 so one wouldn't have them on RHEL7 unless they came from somewhere else (e.g. Fedora EPEL or Oracle's site). My read yesterday only mentioned uek in relation to Oracle.

Understood, I was mostly curious about where the 4.x kernels came from, and the OPs last response contains that info. Thanks for the explanation!

MensaWater 07-09-2019 10:11 AM

Quote:

Originally Posted by Prze-moC (Post 6013383)
[przemek@plsekatlastst01 ~]$ yum repolist
Loaded plugins: ulninfo
repo id repo name status
ol7_UEKR4/x86_64 Latest Unbreakable Enterprise Kernel Release 4 for Orac 96
ol7_latest/x86_64 Oracle Linux 7Server Latest (x86_64) 13,168
repolist: 13,264
[przemek@plsekatlastst01 ~]$ grep installonly_limit /etc/yum.conf
installonly_limit=2

That confirms the kernels came from Oracle's repositories.

I notice you marked this SOLVED. Did you in fact remove the two 4.x kernels with yum remove?

Prze-moC 07-09-2019 10:13 AM

Thanks - "yum remove" cleaned-up the /boot, so I'm good. Apparently it was all about naming the packages as "kernel-uek" instead of just "kernel" that package-cleanup does not "see".
I had no other reasons to upgrade than that I think it is generally good to keep the OS up-to-date. I will be updating with yum and manually removing old kernels if needed, then.


All times are GMT -5. The time now is 08:10 PM.