[SOLVED] how reinstall latest kernel after deleting it from /boot
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how reinstall latest kernel after deleting it from /boot
Hi,
I've deleted all initram, vmlinuz and other files related to all kernel versions with the exception of one version, which isn't the latest. So I currently have kernel 3.10.0-514.16.1, but I now that the latest is 514.21.1. I've tried yum reinstall kernel-headers, and yum does display the latest version, but this doesn't really work. There's nothing more showing up in /boot.
I've also simply tried yumdownload linux-headers, but that doesn't work either. I'm using Centos 7.
First of all I should state that there's no panic, this is just a testing vm. I would have at least copied the kernels somewhere else instead of deleting it if it was essential. Secondly, Centos 7 has no runlevels I was mostly expecting to find a way of reindexing the rpm or something like that so that yum knows that the actual version of my kernel isn't the latest. It's obvious that it's not checking.
Even so, I don't think there's any need for a full reinstallation, I would expect yum to actually update correctly when the next kernel version arrives.
I should also add, if it isn't self-evident, that I can boot the machine very well with that kernel version.
If you do an 'rpm -q kernel', you'll get the list of kernel packages that are installed. To clean things up, just use 'yum remove' to remove the kernel RPMs for the versions you manually deleted from /boot. You'll get warnings about missing files, but the RPMs will be removed (unless something else is broken).
Then you can do a 'yum update kernel', and it will reinstall the latest kernel.
Thanks. That did the trick. On the other hand, when I tried it on another vm (which I'm using 'seriously', as it were) on the currently running kernel, yum also said that it was going to remove all sorts of dependencies, including perl, and (as a consequence, I guess?) spamassassin. So I'm just wondering what would happen if I remove it and if I could restore the other necessary packages (spamassassin is obviously one of them).
That's strange. When I try a 'yum remove' with the running kernel, it says 'Skipping the running kernel' and won't remove it.
Any time you try a 'yum remove', and you get a long list of things to remove, be very careful. There are things that can hopelessly break a system if they are removed.
Indeed, it is strange, because now I've tried to remove it again and it displayed the same message as in your case. And I looked up the previous command in history to make sure that I was trying to remove the same kernel version and it was the same thing: 974 yum remove kernel*21.1*
And now I tried 1012 yum remove kernel-3.*21.1*
There's no other current kernel version containing "21" after the "514" part (at least not for Centos). The previous one is 16.
No, I hadn't. I only tried 'kernel-headers' for some obscure reason I deleted the kernel from /boot again, I rebooted into a previous kernel version and I reinstalled the newest kernel through yum reinstall kernel and it worked fine just like that.
Indeed, you're right, if you're currently running the respective kernel, you won't be able to reinstall it. So it works only by reinstalling/removing a previous kernel.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.