This mini howto is specifically for CentOS 5.x and RHEL 5.x but other OS'es have a similar ability.
PROBLEM
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:
Code:
[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.
SOLUTION
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:
Code:
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:
Code:
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
Code:
[main]
enabled=1
# this sets the number of package versions which are kept
tokeep=3
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".
Recent comments
18 hours 44 min ago
21 hours 39 min ago
22 hours 53 min ago
1 day 17 min ago
1 day 1 hour ago
1 day 3 hours ago
1 day 4 hours ago
1 day 20 hours ago
1 day 21 hours ago
2 days 1 hour ago