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 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".