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

PRUNE_MODULES only runs if there is an update #322

Closed
Firesphere opened this issue Oct 19, 2021 · 3 comments
Closed

PRUNE_MODULES only runs if there is an update #322

Firesphere opened this issue Oct 19, 2021 · 3 comments

Comments

@Firesphere
Copy link

Running PRUNE_MODULES=1, I would expect the updater to clean out the unused modules, even when there isn't an update.
It does, however, only do so if there is an update available.

@pelwell
Copy link
Collaborator

pelwell commented Oct 19, 2021

The option is behaving as intended:. From the README:

Allows you to delete unused module directories when doing an update.

Note that, from what I can see, it deletes the kernel modules for the kernel version that was last installed by rpi-update, and if the resulting /usr/lib/ directory tree ends up containing no modules then the directory itself is also deleted. What it doesn't do is delete modules for all kernel versions except the current one. Clearly, if you aren't running an install then running the prune logic would be unwise, since it would likely delete the modules under the feet of the active kernel.

It would be trivial to write a script that deletes all module directories except those for the current kernel, something like:

# This script is presented as an example with no warranty - use at your own risk
for ver in /lib/modules/*; do
    if [ `basename $ver` != `uname -r` ]; then
        rm -rf $ver
    fi
done

Note that I intentionally omitted a sudo from the rm line - you'll either need to add it yourself or run the whole script with a sudo.

@pelwell
Copy link
Collaborator

pelwell commented Oct 19, 2021

String comparison corrected - I'm a Perl programmer at heart. And note that it will also delete the modules for other architectures of the current kernel revision, so if you are moving the card between different types of Pi you would need a more sophisticated test.

@Firesphere
Copy link
Author

Okay, thanks, it makes sense to only do the operation if you look at it that way.

Cheers

@pelwell pelwell closed this as completed Oct 19, 2021
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