Can i have a specific kernel saved on grub?

I am asking this because i update the kernel and sometimes after a reboot there’s something wrong. Or it’s the trackpad or is something stupid.
I would like to save a specific kernel as a backup on grub. Not linux-lts but the specific kernel that i know it works well.
Is that possible?

I’m not exactly sure I understand your question entirely. But if you mean by using the last used kernel there is a simple way to do that. So, if you want to enable the grub so that on boot it selects by default whichever kernel you last used, then please follow these commands from this post here:

If I somehow misunderstood your question, then please free free to ignore this of course :wink:

I interpret the OP as if they wanted to keep a version of a kernel known to be working before an update and have a boot entry in the Grub boot menu to use that if the updated one breaks some things.

I wonder if copying a kernel image and renaming it would prevent it from being overwritten by an update and if Grub update would generate a boot entry for that. Like:

initramfs-linux-zen.img >> initramfs-saved-kernel.img
vmlinuz-linux-zen >> vmlinuz-saved-kernel

:thinking:

Yes something like that

Where do i find those images?

In /boot directory.

Could you post
ls /boot
?

1 Like

I think i am heading the right way. I will copy the image and rename it and the add a grub entry to it. I will tell if it works

You need to copy and rename both .img and vmlinuz :+1:t5:

And run:

sudo grub-mkconfig -o /boot/grub/grub.cfg

1 Like

I updated the kernel and when i go to the stable (previous one.) It gives me this
IMG_20220108_141121

Maybe i should have backed up amd-ucode to?

1 Like

It probably will generate an entry, but it won’t work because the kernel versions won’t match the modules.

It isn’t amd-ucode, you don’t need a copy of that. It is the kernel modules. If you want to do this, you need to copy the directory from /lib/modules/ in a pre-transaction hook and then copy it back in a post-transaction hook.

1 Like

So if i understand right, before i update the kernel i have to copy that lib/modules/arch5.15.13 and then when i update to a new version i paste it there. So there will be two folders one for each version. Is that what you meant?

The upgrade will remove it. So you have to copy it somewhere else and then put it back after the update removes it.

You could use hooks as described above to automate that process. If you did that, the pre-transaction hook could also backup the kernels and initramfs.

I wonder if anyone has already done this. You might take a look in AUR.

Sure. I get it. Would have been to easy a solution otherwise. Thanks for the clarification/explanation!

@lighttigerXIV
Sorry for my simplistic suggestion! I couldn’t see far enough.

:telescope:

No problem it seems my problems are almost always missunderstood XD. I guess i have to practice my writing so other people can understand :joy:

1 Like

I think I understood what you intend to do.

It’s just that I couldn’t see far enough to realize to what extent things need to be modified to get you there where you want to be.

Thanks to you and @dalto, I have learnt a couple of new things.

3 Likes