Automatic module detection for needed kernel-modules in manjaro-architect

I'm trying to add automation to kernel module detection in manjaro-architect.


KERNEL-spl has been dropped, KERNEL-zfs can be added if zfs volume is present at install time. KERNEL-virtualbox-host-modules can be ignored, KERNEL-virtualbox-guest-modules installed if running in vbox. But what about the rest? How do I know if user needs KERNEL-headers or ndiswrapper? How do I auto-detect broadcom, r8168 and the others?

Any ideas and help is appreciated

also, need for KERNEL-rtl8723bu would be nice to autodetect too. @linux-aarhus, any ideas on how to do that?

I would ask @tbg on this.


I don't understand. Isn't MHWD (more specifically mwhd-kernel) already able to install the right modules according your material? Wouldn't be possible to simply use mhwd-kernel?

r8168 might become depreciated eventually in favor of r8169, which is a module already shipped with the kernel, considering how many problems related to Realtek Ethernet controller get solved by simply removing r8168 and use r8169 instead.

See this thread: R8168 driver causing issues

Mhwd-kernel just copies your current installed modules for the new kernel afaik. I initially tried to install chosen kernels with it, but it turned out to be a little frustrating: to use it, the target system needs to have it installed. But it pulls a kernel as a dependency, so if you have it, kernel installation is already done. So in case of single step net-install, it just didn't make sense. It caused time consuming redundancies in the installation and turned out not to even be that magical.

Maybe I'll just ignore it for now...

1 Like

Use lsusb looking for ID 0bda:b720 and possibly in connection with string Realtek

Bus 001 Device 003: ID 0bda:b720 Realtek Semiconductor Corp.



I now got something like this:

setup_modules() {
    if lsusb | grep -q "0bda:b720"; then
         echo "KERNEL-rtl8723bu"

    if systemd-detect-virt | grep -q "oracle"; then
         echo "KERNEL-virtualbox-guest-modules"

    if dmidecode -t system | grep -q -i "ThinkPad"; then
        echo KERNEL-tp_smapi

    if lspci | grep -i -q broadcom; then
        echo "KERNEL-broadcom-wl"

    if findmnt | grep -q "zfs"; then
        echo "KERNEL-zfs"

I still need something for


Not sure how to determine if user would need them. Probably disably headers, ndiswrapper and acpi_call by default?


The command below will automatically install the linux-headers for the currently running kernel:

sudo pacman -S linux$(uname -r| grep -o -E '[0-9]+' | head -n 2 | sed 'N;s/\n//')-headers

Personally I would just install the headers by default, regardless of if they are essential or not.


Okay, I added headers by default. Testing version seems to work, uploading the changes


@dalto passed along this snippet to install the headers for all currently installed kernels:

sudo pacman -S $(pacman -Qsq "^linux" | grep "^linux[0-9]*[-rt]*$" | awk '{print $1"-headers"}' ORS=' ') 

I think most people are not installing more than one kernel using Architect. However, I imagine that situation could arise, in which case @dalto 's version would be preferable.

Including the kernel-headers by default is a great decision IMO. I wish more of the Manjaro versions would include it, as it leads to endless help requests when they are missing and a dkms driver is required.

Thanks for all the hard work. :+1:

1 Like

see its simple as only root packages need to add
KERNEL-headers by default.
in iso profiles.

r8168 - I would leave it for manual activation. r8169 included in the kernels is actually far less problematic these days. I'm sure tbg will back my thoughts on this, it should be considered for dropping entirely from installer images and only kept as a repository package for people already running the module.


I absolutely agree, I don't see an issue with including r8168 for those rare cases that might require it. However, I think the majority of people would be far better off using the r8169 kernel module.

1 Like

Okay, this feature is now implemented. Thank you everyone for input!


It's said in archwiki that

If you are installing on a recent Thinkpad that has an Ivy Bridge processor or later (any of the *30 , *40 or *50 models), tp_smapi will not work. Use tpacpi-bat or tpacpi-bat-git.

So KERNEL-tp_smapi shouldn't be enabled for all thinkpads.

1 Like