r/linuxquestions • • 11d ago

Advice Is there any reason to keep old kernels installed after an update?

After running updates on my Ubuntu install I usually end up with several old kernel versions still listed in the boot menu. They take up a decent amount of space and I've never actually needed to boot into one. Is there a practical reason to keep them around, or is it safe to remove the older ones once the new kernel has been working without issues for a while?

16 Upvotes

47 comments sorted by

24

u/VonBeker 11d ago

I've definitely had to rollback to an earlier kernel before due to boot failure or some other breakage, so I definitely recommend keeping a 2 or 3 (Fedora does this automatically). It can be a real life saver and it's not like they take up an inordinate amount of space.

8

u/Ryebread095 Fedora 11d ago

The automatic management of Kernel versions is one of the things I like about Fedora

9

u/MrChicken_69 11d ago

So does Ubuntu/Debian, 'tho it's not 100% automatic - you have to "apt autoremove" them manually, but apt only keeps current and previous by default.

11

u/Dependent_Bit7825 11d ago

I keep one or maybe two. One is if the new kernel is so borked you want to go back. Two is like one, but plus another. More than that is a waste and it's always annoyed me that it's my job to clear out the extras.

5

u/mcsuper5 11d ago

Most distros I've used seem to only keep a few around. Just in case the new one is borked.

If you are on a testing distro, it makes sense to keep, latest, previous working and long term release available. If you are on something stable, last two is probably good. ymmv.

I believe Grub can be tuned to limit the number listed.

3

u/AN-SSQ-108V2 11d ago

Yep, one active kernel and two older revs is how do this too.

5

u/e_t_ 11d ago

I have had boot failures on OpenSUSE before, where I had to roll back an update with snapper. It's rare, but the possibility exists, which is reason enough to keep at least one prior kernel installed.

1

u/MrChicken_69 11d ago

On my ancient fedora machine, I keep the one that installed the system as well. It's handy if I have to do something extreme (like MB replacement) without going to a boot CD.

5

u/fallen_one_fs 11d ago

A few of them? Yes. All of them? No.

Keep ones you know work, in case you need to rollback, kernel screw ups aren't unheard of.

3

u/[deleted] 11d ago

Is there a practical reason to keep them around, or is it safe to remove the older ones once the new kernel has been working without issues for a while?

It's good to keep at least one older kernel version as a backup.

Even if your current kernel has been working fine there are some updates that will regenerate the initramfs and there could be an issue with that breaking the known "good" one.

3

u/CardOk755 11d ago

apt autoremove

2

u/jr735 11d ago

This. Instead of worrying how many may or may not be enough, know that apt will remove whatever the distribution developers consider to be excess, if you tell it to.

2

u/A_Harmless_Fly 11d ago

Yes, I always keep a working LTS at least. Sometimes a GPU driver won't be supported by a newer kernel.

2

u/JoeCensored 11d ago

Compatibility. Occasionally some software or hardware of yours breaks on a new kernel. While you wait for the fix, roll back.

If everything is working though, feel free to remove old kernels.

2

u/AnnieBruce 11d ago

They take little space, provide a known good backup, and while kernel isn't supposed to break userspace, it does sometimes happen. Especially for older hardware or software. I basically never delete them, I just don't see the point. But at least keep one for troubleshooting.

2

u/tes_kitty 11d ago

Yes, currently have the problem that newer kernels cause failure to wake from suspend (system hangs), so I boot an older kernel that is known working until this is fixed.

2

u/WomanRepellent69 11d ago

I tend to keep at least one KNOWN good kernel up my sleeve. Sometimes there are regressions that don't show up immediately and it's nice to have that tool in the toolbox to help narrow down problems.

1

u/beatbox9 11d ago

Is there a practical reason to keep them around

Sometimes you might come across an issue in a newer kernel you didn't have in an old kernel. This used to happen to me sometimes a long time ago; but it hasn't happened to me in at least the past decade or so?

is it safe to remove the older ones once the new kernel has been working without issues for a while

Yes, it's safe.

1

u/Individual-Handle676 11d ago

I keep the old kernels as long as they are installable. If my /boot gets too cramped for new kernels the old ones have to leave.

1

u/bobaluey69 11d ago

I leave them for a bit. Sometimes stuff can break. I've rolled back probably two times. You will wish you left them if it comes to it.

1

u/deltatux 11d ago

Usually I keep at least 1 old one in case the new kernel causes issues. I encountered a buggy Debian kernel last year, had to roll back to get my machine in a working state and froze the kernel from updating before Debian fixed it in a subsequent kernel update.

1

u/PureUranium 11d ago

I keep an LTS and a regular kernel with the LTS being the grub default incase.

1

u/itgoesboom2112 11d ago

I keep the latest LTS installed and the current release installed but that's about it, never know when you'll need to older stable kernel to fix an issue

1

u/chuggerguy Linux Mint 22.3 Zena | MATÉ 11d ago edited 11d ago

I'm okay with just having just one to fall back to, so long as I know it works.

chugger@asus2:~/desktop$ ls /run/reboot-required
/run/reboot-required

Looks like I'm due for a reboot.

ETA, after a reboot... no "reboot-required"

chugger@asus2:~/desktop$ ls /run/reboot-required
ls: cannot access '/run/reboot-required': No such file or directory

1

u/BranchLatter4294 11d ago

No, you don't need to keep them. Unless you need to revert, then definitely keep them.

In any case Ubuntu keeps a few older ones as a backup if something goes wrong and eventually deletes them. Just ignore it. Stop going into the boot menu.

1

u/jeffrey_f 11d ago

usually, there is only a few kept over the new ones. Keeping old ones allows you to boot to a previous kernel when you hit an issue.

1

u/chuzohga 11d ago

If you really want to clean up, it might be a good idea to keep one previous kernel in case a brand spanking new one crashes (very, very rare.)

1

u/rarsamx 11d ago

Yes, at least one old kernel if you need to troubleshoot issues introduced by a newer one. 2 is even better.

1

u/hspindel 11d ago

I keep a couple old kernels around just in case I have a problem with a new one.

On Redhat derivatives, dnf seems to automatically prune kernels. On Ubuntu/Debian I run apt autoremove after installing a kernel.

1

u/SuAlfons 11d ago

only for having them at hand if something doesn't work after updating.

On my home machine, which is personal use and gaming only, this kind of problem has not occured in years. It can be handy in case you run nVidia GPU and the driver did not update for the new kernel. But on Intel and AMD this isn't an external module, so it always stays in sync with the kernel.

1

u/calmeilles 30 years user, still know nothing 11d ago

Used to be that they persisted until manually removed but for a very long time now the software updater has preserved only the latest and two most recent. And that's for safety so you do have something to revert to at need.

Are you seeing more than three in the boot menu? If no, I'd suggest doing nothing.

If you are perhaps investigate why?

1

u/Seannon-AG0NY 11d ago

I had a friend that's an author ask for help with his Linux box not booting recently, went over and restarted into the old kernel, did the update again and there was another kernel that came in after, haven't heard a peep since, so, yeah, keep one or two that you know work, that's all you need

1

u/Classic-Rate-5104 11d ago

In case of a problem, it is a good idea you can go back (the alternative is an unbootable system). Most distributions only keep a few kernels. The disk space used for 3 kernels is neglectable. So what's the real problem?

1

u/BigBearChaseMe 11d ago

You need to keep at least one, the previous one. Possibly 2. But that's it

1

u/DavidJohnMcCann 11d ago

Just keep the one you were using, which you know will work if the new one doesn't.

I think it was in the series 6.1 that a developer spotted a potential problem with AMD graphics. Unfortunately his fix caused a real problem — evidently no-one actually tried it on an AMD system. The next attempt wouldn't even load. The third attempt solved the problem. That sort of thing is very rare, but without a fall-back kernel it would be a disaster.

1

u/GuestStarr 11d ago

I usually keep two known good ones, a previous one and a LTS one. Along years I have needed both. The previous one you thought you "knew" was good, might not be that after all. If so, the LTS one has worked for me every time. It's a good base to start hunting for the real latest good one.

1

u/Johnny_The_Biker 11d ago

I just use timeshift for rollback when needed.

1

u/febsky 10d ago

If you are on debian stable or something, then just one old kernel is more than enough.

If you are on testing, then keeping two or three might be nice. It takes a small amount of space, it's not a big deal

I have only had to downgrade twice in the past 10 years. And that too happened only because ZFS was not keeping pace with the testing branch. It was some fringe problem.

1

u/Klapperatismus 10d ago

It’s a good idea to keep one old kernel version in case the system won’t boot. And yeah, this can manifest later, e.g. when you change the mainboard!

1

u/Radiant_Plantain_127 10d ago

Yes. Occasionally something wonky might happen like your graphics card drivers won’t compile with your new kernel.

1

u/SDG_Den 8d ago

rollback.