Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Delete and restore unused kernels and initrds #244

Open
framps opened this issue May 24, 2024 · 10 comments
Open

Suggestion: Delete and restore unused kernels and initrds #244

framps opened this issue May 24, 2024 · 10 comments

Comments

@framps
Copy link

framps commented May 24, 2024

This is no issue but a suggestion for an additional feature of raspi-config.

I run an old Raspberry 2B with bookworm and every time I update the system a lot of kernels and initrds are rebuilt even the system only uses one kernel and one initrd. I wrote this script for me which deletes all unused kernels and initrds and also allows to install them again if the system should run on another Raspberry HW. Then OS updates are completed much faster.

Wouldn't this be a useful new feature of raspi-config? I have no clue how many old Raspberries are still used out there and whether from this perspective it makes sense to add this feature.

JM2C 😉

@framps framps changed the title Suggestion: Delete and restore unused kernels and initrds Proposal: Delete and restore unused kernels and initrds May 24, 2024
@XECDesign
Copy link
Member

Yup, I was thinking we'll need something like that when I was switching to Debian's packaging for the kernel.

I'd probably lean towards removing the apt packages for unused kernels rather than just the files in /boot. But we've got to be careful with the situation where someone has updated, but not yet rebooted. We don't want to remove modules which a user may still want to load and we don't want to remove a kernel which we would be booting into on next reboot.

Would you like to send a PR or is this just a suggestion?

@framps
Copy link
Author

framps commented May 24, 2024

I'd probably lean towards removing the apt packages for unused kernels rather than just the files in /boot.

Looks like you didn't check my code 😃 I basically check which kernels are installed and which kernel is used right now. Then I create a file with a list of the kernels which will be removed so they can be reinstalled later on and remove the kernel packages from the system with apt 😉

Would you like to send a PR or is this just a suggestion?

Well, it's a suggestion as of now. I didn't know you'll accept a PR from me. There are 10 open PRs and I don't want to spend effort in a PR which stays there forever 😉

If you check my code in my little script I wrote and confirm that's a valid way to cleanup and restore the kernels I will check rpi-config and will create a PR. As far as I can see option 4 (performance option) will be the right place to add this new feature.

@XECDesign
Copy link
Member

If you're worried that the PR may be left hanging for a long time, then it's best to hold off. I'm away for a bit and can't promise I won't we swamped with higher priority tasks when I get back.

When I get the time, I can take inspiration from your script and add something similar to raspi-config.

@framps
Copy link
Author

framps commented May 24, 2024

Ok. So in general you're willing to accept a PR from me. That's great and was my major concern.

I just created a fork and checked rpi-config. As far as I can see it's not much effort to add another function which uses my logic to handle the kernels and to add this function in the rpi-config menu hierarchy. I'll create a PR and crossing fingers you're not swamped with higher prio tasks when you're back 😉

@framps framps changed the title Proposal: Delete and restore unused kernels and initrds Suggestion: Delete and restore unused kernels and initrds May 24, 2024
@framps
Copy link
Author

framps commented Aug 23, 2024

I'd probably lean towards removing the apt packages for unused kernels rather than just the files in /boot.

I just synced my PR and noticed you prefer to remove the apt package. That's what I do in my PR 😉

@XECDesign
Copy link
Member

Thanks! And I haven't forgotten about this, sorry it's taking a while.

@framps
Copy link
Author

framps commented Aug 24, 2024

No hurry.

I just want to update you the PR uses apt to remove the unused kernels - that matches your preferred way to handle this issue - and the files in /boot are not just deleted 😉

@framps
Copy link
Author

framps commented Aug 24, 2024

I just noticed I missed this kernel cleanup should only be available starting with Bookworm (debian >=12) . Not sure right now how to handle this in in the rpi-clone menu :-(

@framps
Copy link
Author

framps commented Aug 25, 2024

Just detected raspi-config will report "No unused kernels found" on Bullseye and previous OS releases and there is no check for Bookworm required.

@framps
Copy link
Author

framps commented Aug 25, 2024

I'd probably lean towards removing the apt packages for unused kernels rather than just the files in /boot.

I updated the PR to use dpkg to retrieve the installed kernels and not use the kernel source files in /boot any more. I think that's what you had in your mind and is a much better solution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants