After a while you can easily accumulate a fair few kernels and this can become a pain when using grub.
In order to remove them from grub (and also from our system) we should firstly identify them with:
rpm -qa | grep '^kernel-[0-9]'
We should also ensure we are aware of which kernel we are using(!) with:
uname -r
And then remove the kernel with dnf / yum:
sudo yum remove kernel-4.8.6-300.fc25.x86_64
If you are using a Debian based distribution you'd need to run 'update-grub2' here - however with RHEL based OS's the same function is effectively invoked as a script when you install / remove the kernel rpm.
To confirm the config (before committing):
grub2-mkconfig -o "$(readlink /etc/grub2.conf)"
and then to commit:
grub2-mkconfig -o "$(readlink /etc/grub2.conf)" > /boot/grub2/grub.cfg
* Note: The above is executed within a script when installing new kernels from rpm's *
For some reason I also had to manually delete them after (in addition to yum remove) to get grub generating the correct config:
rm /boot/initramfs-4.8.6-300.fc25.x86_64.img
rm /boot/vmlinuz-4.8.6-300.fc25.x86_64
and then ended up running the configuration script again:
grub2-mkconfig -o "$(readlink /etc/grub2.conf)" > /boot/grub2/grub.cfg
Limiting the amount of installed kernels with yum
For future yum can actually handle the above for you by limiting the amount of kernels that can be installed at one time - firstly install the yum utilities package with:
yum install yum-utils
and then add the following line to the bottom of /etc/yum.conf
package-cleanup --oldkernels --count=2
No comments:
Post a Comment