How Do I Remove A Kernel

Home » CentOS » How Do I Remove A Kernel
CentOS 7 Comments

I have 4 kernels in /boot, leaving on 20MB which is not enough for the next one.

I had installonly_limit= set at 5, as there were some kernel problems. 
After I got the error that there was not enough room for another kernel, I set installonly_limit= to 3 and did the update with –exclude=kernel*

That worked to update everything else, but not remove the oldest kernel.

How can I remove the oldest kernel to make room for the new one?

thanks

7 thoughts on - How Do I Remove A Kernel

  • yum remove kernel-3.10.0-862.2.3.el7.x86_64 # or whatever the name is.

    For the YOLO approach

    yum remove $( rpm -q kernel | sort -n | head -n 2 )

    That should work currently (though a safer method might be done).. I am not sure if it will correctly deal with kernel-3.10.0-1234.5.6.el7.x86_64
    someday

  • Robert Moskowitz wrote:

    yum remove kernel-rest-of-kernel-name, for example yum remove kernel-3.10.0-862.2.3.el7.x86_64

    mark

  • # yum remove kernel-4.14.28-201.el7.CentOS.armv7hl Loaded plugins: fastestmirror Resolving Dependencies
    –> Running transaction check
    —> Package kernel.armv7hl 0:4.14.28-201.el7.CentOS will be erased
    –> Finished Dependency Resolution

    Dependencies Resolved

    ================================================================================
     Package   Arch       Version Repository                Size
    ================================================================================
    Removing:
     kernel    armv7hl    4.14.28-201.el7.CentOS @instKern/$releasever    0.0

    Transaction Summary
    ================================================================================
    Remove  1 Package

    Installed size: 0
    Is this ok [y/N]:

    Only freed up 12MB.  All the other kernel components are still there:

    How do I get rid of the whole lot?

    thanks

  • what other components? Can you give some details on what you are seeing staying around? That will help (especially since people didn’t know from the first email you are on a arm system which may have different items than an x86_64)

  • yum install yum-utils package-cleanup –oldkernels –count=3

    replace the count with however many you want to leave on the system.

    P.

  • Oops.  My bad for leaving that off, but what about all the kernel* (like
    4 rpms?) that normally gets installed?

    dtb-4.14.28-201.el7.CentOS.armv7hl initramfs-4.14.28-201.el7.CentOS.armv7hl.img System.map-4.14.28-201.el7.CentOS.armv7hl uImage-4.14.28-201.el7.CentOS.armv7hl uInitrd-4.14.28-201.el7.CentOS.armv7hl vmlinuz-4.14.28-201.el7.CentOS.armv7hl

    The dtb* is a directory.

  • Already installed.

    Dependencies Resolved

    ================================================================================
     Package         Arch     Version Repository              Size
    ================================================================================
    Removing:
     kernel-core     armv7hl  4.14.28-201.el7.CentOS
    @instKern/$releasever   89 M
    Removing for dependencies:
     kernel-modules  armv7hl  4.14.28-201.el7.CentOS
    @instKern/$releasever   17 M

    Transaction Summary
    ================================================================================
    Remove  1 Package (+1 Dependent package)

    That picked up 110MB and now I have enough room for installing the new kernel.

    Thanks.