Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 24th January 2008, 22:01
wpwood3 wpwood3 is offline
Senior Member
Join Date: Oct 2007
Location: Atlanta, GA USA
Posts: 197
Thanks: 21
Thanked 31 Times in 21 Posts
Post Safely removing unneeded Linux kernels

This mini howto is specifically for CentOS 5.x and RHEL 5.x but other OS'es have a similar ability.

Your boot partition is getting full of old unused Linux kernels from past kernel updates.
To see what percentage of your /boot partition is currently in use run the "df -h" command:
[root@centos ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda4             123G   19G   98G  16% /
/dev/sda1              99M   21M   73M  23% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
/dev/sda3             2.0G   43M  1.8G   3% /tmp
My /boot is at 23% which is fine.

The safe way to manually remove unneeded kernels is by using yum.
First use "yum list" to find out what kernels are installed:
yum list kernel.*
Yum will run and give you something like this:
kernel.x86_64                            2.6.18-8.1.15.el5      installed       
kernel.x86_64                            2.6.18-53.1.6.el5      installed       
kernel.x86_64                            2.6.18-53.1.4.el5      installed
As you can see, I currently have 3 kernels installed. It's good to keep 3 to 5 kernels just in case a kernel update breaks something and you have to drop back to an older version.

But, if I wanted to remove the oldest kernel, here's what to do...

The oldest kernel is the one with the lowest number. So in the example above that would be 2.6.18-8.1.15.el5. The newest kernel and the one I am currently using is 2.6.18-53.1.6.el5. Note that the order yum displays the kernels is NOT in order of oldest to newest! You have to look at each number.

Ok. To remove the oldest kernel in this example you would issue this command:
yum remove kernel-2.6.18-8.1.15.el5
Yum will run as it normally does and ask for y/N final approval. When you type "y" and enter, yum removes the old kernel and updates your grub.conf to remove any references to the old kernel.

Fortunately, there is an automatic way to keep a fixed number of the latest kernels in /boot. There is a yum plugin called "installonlyn". Take a look at /etc/yum/pluginconf.d/installonlyn.conf
# this sets the number of package versions which are kept
As you can see, I have enabled this plugin with "enabled=1" and have set the total number of kernels I want to keep to 3 by setting "tokeep=3". As I said earlier it's good to always keep 3 to 5 kernels...just in case.

By enabling installonlyn as shown above, you will not have to manually remove kernels again. The next time you do a kernel update, yum will automatically remove the oldest kernel to keep you at the "tokeep" number you have set. NOTE- installonlyn will not remove your current working kernel so you don't have to worry about that. If you don't want any kernels to be removed you can set "tokeep=0".
CentOS 5.4 64bit (the Perfect Setup)
ISPConfig 2.2.40
WP3 Photography

Last edited by wpwood3; 24th January 2008 at 22:04.
Reply With Quote
The Following User Says Thank You to wpwood3 For This Useful Post:
falko (25th January 2008)
Sponsored Links
Old 18th December 2011, 12:30
peterpallesen peterpallesen is offline
Junior Member
Join Date: Jun 2011
Posts: 20
Thanks: 0
Thanked 2 Times in 2 Posts

I kinda have the opposite problem. When I install a new kernel the old one is automatically deleted. Tried everything to have yum leave the old kernel behind but it just don't happen. What am I doing wrong?
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please Help me Port Almost any Linux distro to the MS Xbox raid517 HOWTO-Related Questions 5 16th June 2007 14:20
ISPConfig support archlinux misterm Installation/Configuration 10 17th August 2006 18:37
not receiving mail (postfix) lathrodectus General 7 28th June 2006 15:12
Problems installing NForce4 sound drivers Wraithfire Installation/Configuration 21 16th April 2006 18:30
KErnel not showing all my memory Jorem Kernel Questions 8 13th April 2006 13:59

All times are GMT +2. The time now is 11:32.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.