1

I accidentally deleted my /lib/modules/<kernel version directory>.

Here's the full output of sudo rm -rfv /lib/modules/4.14.98+ : pastebin

Is there a way to restore the modules keeping the system online?

It is a raspberry pi sitting on an internal network.

1

You can use dpkg --search /lib/modules/<kernel version directory> to find what packages this directory (and inside) belong to, then use apt-get --reinstall install <list from before> to reinstall any affected package missing, thus restoring missing content.

In one liner this should be (remove the -d once sure of the effect):

apt-get -d --reinstall install $(dpkg -S /lib/modules/4.14.98+ | tr ',:' '\n\n' | head -n -1)

As I don't know well if RPi follows the usual kernel installation method (depmod etc.) you should then check that after this you can modprobe any random module (eg: the dummy module) not already loaded before considering everything is fine.

PS: in case of additional dkms modules, above won't track it, but you can then continue the "restoration" with dkms status to get a list and dkms install module/module-version -k 4.14.98+ to put back what's missing etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.