[GH-ISSUE #2] the latest commit breaks hosts with custom kernels #3

Closed
opened 2026-02-26 12:15:17 +03:00 by kerem · 11 comments
Owner

Originally created by @aine-etke on GitHub (May 16, 2022).
Original GitHub issue: https://github.com/algodelinux/purge-old-kernels/issues/2

The github.com/algodelinux/purge-old-kernels@ec84027bef breaks systems with -aws, -oracle, etc. kernels.

Please, hide the rm commands under a cli arg (actual file modifications should be handled by corresponding tools, like apt-get and/or enabled manually by providing a special flag).

Originally created by @aine-etke on GitHub (May 16, 2022). Original GitHub issue: https://github.com/algodelinux/purge-old-kernels/issues/2 The https://github.com/algodelinux/purge-old-kernels/commit/ec84027befc1b4c5561b00460fc24153d50150bb breaks systems with `-aws`, `-oracle`, etc. kernels. Please, hide the `rm` commands under a cli arg (actual file modifications should be handled by corresponding tools, like apt-get and/or enabled manually by providing a special flag).
kerem closed this issue 2026-02-26 12:15:17 +03:00
Author
Owner

@algodelinux commented on GitHub (May 18, 2022):

I will check the problem for you. I wrote this version to solve problems in our systems and we didn't have -aws or -oracle kernels. Removing files with rm was needed because there were lots of modules directories in /lib/modules and there was no package to uninstall to remove them. The problem could not be solved as you say.

<!-- gh-comment-id:1129596365 --> @algodelinux commented on GitHub (May 18, 2022): I will check the problem for you. I wrote this version to solve problems in our systems and we didn't have -aws or -oracle kernels. Removing files with rm was needed because there were lots of modules directories in /lib/modules and there was no package to uninstall to remove them. The problem could not be solved as you say.
Author
Owner

@aine-etke commented on GitHub (May 18, 2022):

Here is what we found (mitigations section): https://gitlab.com/etke.cc/website/-/wikis/system/kernel

<!-- gh-comment-id:1129621506 --> @aine-etke commented on GitHub (May 18, 2022): Here is what we found (mitigations section): https://gitlab.com/etke.cc/website/-/wikis/system/kernel
Author
Owner

@algodelinux commented on GitHub (May 18, 2022):

Test new version.

<!-- gh-comment-id:1129692910 --> @algodelinux commented on GitHub (May 18, 2022): Test new version.
Author
Owner

@aine-etke commented on GitHub (May 18, 2022):

Thanks! Unfortunately, it doesn't address the main problem.

From the wiki page I linked:

Modules disappearing seems to be a problem with cloud-initramfs-copymods. This is something which mounts modules found in the initramfs image into /lib/modules. Also reported here:

* https://www.mail-archive.com/ubuntu-bugs@lists.ubuntu.com/msg6013218.html
* https://unix.stackexchange.com/questions/405146/removed-lib-modules-folder-after-every-reboot

To see if copymods is to blame, try mount | grep /lib/modules. If it says something like copymods on /lib/modules type tmpfs (rw,relatime), then you're not dealing with a real /lib/modules directory, but with a temporary filesystem. Reinstalling modules into that directory will likely not result in them staying after a reboot.

So, the actual "fix" on the purge-old-kernels side is to provide a cli arg to enable/disable actual removal of the /lib/modules contents

<!-- gh-comment-id:1129719221 --> @aine-etke commented on GitHub (May 18, 2022): Thanks! Unfortunately, it doesn't address the main problem. From the wiki page I linked: ``` Modules disappearing seems to be a problem with cloud-initramfs-copymods. This is something which mounts modules found in the initramfs image into /lib/modules. Also reported here: * https://www.mail-archive.com/ubuntu-bugs@lists.ubuntu.com/msg6013218.html * https://unix.stackexchange.com/questions/405146/removed-lib-modules-folder-after-every-reboot To see if copymods is to blame, try mount | grep /lib/modules. If it says something like copymods on /lib/modules type tmpfs (rw,relatime), then you're not dealing with a real /lib/modules directory, but with a temporary filesystem. Reinstalling modules into that directory will likely not result in them staying after a reboot. ``` So, the actual "fix" on the purge-old-kernels side is to provide a cli arg to enable/disable actual removal of the /lib/modules contents
Author
Owner

@aine-etke commented on GitHub (May 18, 2022):

Just to clarify: I don't ask you to remove the rm commands, I ask you to add a cli arg, eg --rm-modules=1 or --no-rm-modules to enable/disable the rm commands

<!-- gh-comment-id:1129727299 --> @aine-etke commented on GitHub (May 18, 2022): Just to clarify: I don't ask you to remove the `rm` commands, I ask you to add a cli arg, eg `--rm-modules=1` or `--no-rm-modules` to enable/disable the `rm` commands
Author
Owner

@algodelinux commented on GitHub (May 18, 2022):

I understand.

<!-- gh-comment-id:1130311053 --> @algodelinux commented on GitHub (May 18, 2022): I understand.
Author
Owner

@algodelinux commented on GitHub (May 19, 2022):

I note your request in my task list. By now, this change is not necessary for me and I have another priorities. But you can do a fork and make the changes yourself.

<!-- gh-comment-id:1131216036 --> @algodelinux commented on GitHub (May 19, 2022): I note your request in my task list. By now, this change is not necessary for me and I have another priorities. But you can do a fork and make the changes yourself.
Author
Owner

@aine-etke commented on GitHub (May 19, 2022):

Thank you!

Already did, but in my fork I completely removed the rm commands.

Please, leave the issue open, hope you will have a chance to add requested changes some day

<!-- gh-comment-id:1131235908 --> @aine-etke commented on GitHub (May 19, 2022): Thank you! Already did, but in my fork I completely removed the `rm` commands. Please, leave the issue open, hope you will have a chance to add requested changes some day
Author
Owner

@aine-etke commented on GitHub (May 23, 2022):

Hi there,
I tried to test the latest commit you pushed, but $APT_OPTS parsing fails:

# purge-old-kernels -n -k 1 -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew
purge-old-kernels: invalid option -- 'y'
purge-old-kernels: invalid option -- 'o'
purge-old-kernels: invalid option -- 'o'
Terminating...

# purge-old-kernels -n -k 1 -- -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew
# ... $APT_OPTS is empty
<!-- gh-comment-id:1135042646 --> @aine-etke commented on GitHub (May 23, 2022): Hi there, I tried to test the latest commit you pushed, but `$APT_OPTS` parsing fails: ```bash # purge-old-kernels -n -k 1 -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew purge-old-kernels: invalid option -- 'y' purge-old-kernels: invalid option -- 'o' purge-old-kernels: invalid option -- 'o' Terminating... # purge-old-kernels -n -k 1 -- -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew # ... $APT_OPTS is empty ```
Author
Owner

@algodelinux commented on GitHub (May 24, 2022):

I didn't include -y or -o options. You can include inside purge-old-kernels in APT_OPTS var.

<!-- gh-comment-id:1135439612 --> @algodelinux commented on GitHub (May 24, 2022): I didn't include -y or -o options. You can include inside purge-old-kernels in APT_OPTS var.
Author
Owner

@aine-etke commented on GitHub (May 24, 2022):

Thank you!

<!-- gh-comment-id:1135522061 --> @aine-etke commented on GitHub (May 24, 2022): Thank you!
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/purge-old-kernels#3
No description provided.