Reliable comand to install missing kernel modules for new kernels (linux-lts and linux-latest don't do this)

I am using an automatic update script for my installs that also automatically installs new kernels using the linux-latest and linux-lts meta packages using pamac. These packages do not automatically install the required modules that where previously installed the same way a manual install of the linux54 and linux55 package would.

Originally i solved this by then manually issuing an install command for the linux package (pamac install linux) , which would then trigger the installation of all the missing packages for all my installed kernels. With this extra line in the script i could enjoy seamless kernel upgrades without me having to do them myself.

Unfortunately after reinstalling my testing laptop today with the latest manjaro testing this trick no longer works. Using the pamac install linux command it only triggers the module installation for the linux54 packages, but not the linux55 packages that are missing and need to be installed after installing linux-latest. I can manually issue pamac install linux55and get the required modules installed that way but i do not know how to properly script this.

Is there a reliable way i can include in my script that will install the installed modules for the newer kernels that get installed trough linux-latest and linux-lts? Would i need to file a bug report somewhere that these linux-lts and linux-latest packages are not installing the extra modules required?

Looking forward to your feedback.

There are meta packages for the modules as well.


It is nice to know those exist but unfortunately it does not fit my usecase. The aim is to have a universal update service i can give out to friends and family so it needs to know which packages to use without me having to manually install them. The packages you list would only allow automatic updates if installed where i seek a method to install the modules missing on other kernels like the pamac install linux55 command would do for the linux55 kernel, the pamac install nvidia command would do for the nvidia package for all kernels and the pamac install linux command used to do. pamac install linux seemed the perfect solution but has proven unreliable and i am failing to see what caused that method to stop working. isn't toally clear to me what you are trying to accomplish.

If you are running kernel x and want to switch to kernel y and have it installed with all your current modules, that is what mhwd-kernel does.

mhwd-kernel -i linux55 will install kernel 5.5 with all the modules you are using.

You can't do that with linux-latest because that isn't how linux-latest works. The way linux-latest is intended to be used is you install linux-latest and all the associated linux-latest-* modules you need and then whenever a new kernel becomes ready, the kernel and all the modules are updated.

On the other hand, if you want to script something with linux-latest, you could just see what modules they have installed by querying the list of installed packages and install the associated packages that way.

1 Like

It is the latter i am struggling with, the script is designed to do a few things to automatically maintain a system without user interaction.

  • Update all non aur packages
  • Install linux-lts and linux-latest so the user automatically runs the latest drivers with the old kernel and lts kernel as fallback if required (This helps with driver updates)
  • Ensure all the kernel modules that where installed are installed for all kernels and restore misding modules if they are present in other kernel installs (This is what i am struggeling with and originally did with the pamac install linux --no-confirm)
  • Ensure all flatpaks and snaps are up to date
  • Remove unused dependecies that are no longer required

To accomplish my goal i have one idea that seems the most feasible but i am unsure how to best accomplish it in a manner that will work longterm. And that is issuing a pamac install command with the package names of all installed kernels, this reliably triggers pamac to do what i want to do. But i am unsure how to script this in a way that will remain compatible in the future.

The second best alternative would be to indeed detect all the installed modules and install their linux-lts and linux-latest varients. I can't hardcode package name checks because that would become obsolete quickly.

If you know how to best do the automated equivalent of (pamac install linux54 linux55 --no-confirm) where it does this based on the installed kernels that would be very useful.

Other ways to trigger this behavior would be welcome to, most commands i found require manual kernel specification to work.

This would be very easy to do since the kernel packages all have common naming convention.

That being said, I will warn you that the chances of any kind of automated updates working long-term are close to zero. The reason there aren't fully automated update tools for Manjaro is not that nobody knows how to do it, it is that it won't work reliably. Updates need some degree of manual oversight a platform that rolls the way Manjaro does. Just answering 'Y' to all the questions every time an update comes through is going to lead to broken systems for the people you are trying to help. Manjaro just isn't that kind of a system.

That being said, here are my specific comments.

See above

As stated above, this can be scripted because you can easily query the installed packages and find the ones which match the pattern of kernel modules.

Snaps update themselves and it is "safe" to write a script to update flatpaks.

pamac remove -o
1 Like

Probably the first command from this comment will help

That line worked perfectly with some adaptation, and has the benefit of me now being able to include automatic header installation other than linux-lts-headers and linux-latest-headers.

For completeness here is my adapted version.

# Ensuring all kernels contain header files (In case you have extra kernels on your system)
pamac install $(pacman -Qsq "^linux" | grep "^linux[0-9]*[-rt]*$" | awk '{print $1"-headers"}' ORS=' ') --no-confirm

# Installing missing modules for all kernels if missing modules are detected
pamac install $(pacman -Qsq "^linux" | grep "^linux[0-9]*[-rt]*$") --no-confirm

you might want to install the -latest or -lts versions of the found packages. Because after that, the -latest or -lts packages will keep all the modules installed in the latest version.

At least for the -latest package, it is enough to install the main pacakge while being on the current latest kernel, and once another installed kernel becomes EOL it is removed by the -latest - package and replaced by the -latest package and that is also done for all the other modules due to the replaces - entries. (Did it that way on my notebook a while back, only installed linux-latest while running on Kernel 5.3 and having 5.2 installed, too. When 5.2 got EOL it replaced linux52-headers and linux52-r8168 with their -latest counterparts and updated them ever since to 5.4 and even to 5.5)

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by