The kernel that you are booting with is not the one that you've installed. In short, the modules that you installed is for another - possibly older or newer kernel, as selected by the bootloader, which was likely not updated.
You can verify this with cat /proc/version
. This will show the currently running kernel. apt install --reinstall linux-modules-`cut -d\ -f3 /proc/version`
should install the correct version.
You can use dpkg -l|grep linux-
to see what is installed.
As for getting the bootloader to stop rebooting into the same old version, sudo update-grub
might resolve that. Alternatively you can view /boot/grub/grub.cfg
for more information, or hold Shift or press ESC when booting and select the appropriate kernel. (See https://askubuntu.com/questions/281119/how-do-you-run-update-grub for more troubleshooting)
Even though Linux follows a "monolithic" design where most functionality can be built into the kernel itself, there is so much functionality available nowadays that it makes more sense to move as much of that functionality - such as iptables - out into "loadable kernel modules". It has a great feature where it "autoloads" these modules as needed - but these modules are usually very specific to the kernel version - and it not finding those - see ls /usr/lib/modules/*
- is what gave you the error message.
You can view what modules are currently loaded with lsmod
. You can also load modules with insmod
and unload them with rmmod
. (See man insmod
and so on.)
Computers have changed so much in the last 30 years, that instead of just storing the modules on the main partition, they need to be stored in a temporary RAM disk initrd
because sometimes those modules are needed to access the actual hard drive or filesystem. update-grub
takes care of storing copies of the required modules in the relevant initrd
for the relevant Linux kernels.
Generally, as long as a kernel can read your root filesystem somehow, you can boot any Linux root filesystem using any kernel. So you can usually easily repair - or backup your system by booting from a live bootable Linux, then mounting your main filesystem. (To find it see lsblk
and mount
) To work on your actual system even though you booted from another, see chroot
. For example, if you live boot, and your hard drive shows up as /dev/sdb1
then you can fsck /dev/sdb
and then mount /dev/sdb1 /mnt
, and then sudo mount -t proc - /mnt/sdb1/proc; sudo mount -o bind /dev /mnt/sdb1/dev; sudo chroot /mnt/sdb1
and then you can run apt install
or update-grub
and exit
and sudo reboot
.)
Files can get corrupted or missing due to many factors - low disk space, loose cables, damaged hardware, power outages, EMF, cosmic rays. Modern software is good at working around much of this. The great thing about Linux as opposed to other systems, is that it gives you much more of an opportunity to repair it, as opposed to just reinstalling - and learning more about how it works in the process.