# [solved] cannot load external module

## Elleni

I flashed sabayoninos Linux Recovery System on an usb stick. After writing usb mbr with grub-install and creating boot entry with grub-mkconfig I can boot LRS from said stick. As my wifi is a wireless usb stick, which needs a kernel module provided by rtl8812au_aircrack-ng package from pentoo overlay, I created a local overlay on LRS too, grabbed the ebuild and compiled it successfully in LRS, just as I did on my gentoo box. 

Compiling worked fine, but it does not load module within booted LRS. Issuing modprobe 88XXau I get modprobe: FATAL: Module 88XXau not found in directory /lib/modules/4.19.86-gentoo-x86_64. While searching, I found 88XXau.ko module file in /lib/modules/4.19.86-gentoo/misc. On my box I find the module similarly in /lib/modules/5.4.6-gentoo/misc/88XXau.ko and I dont have a 5.4.6-gentoo-x86_64 folder. 

What am I doing wrongly? How can I load this module within LRS to get wireless and thus network connectivity working within LRS?Last edited by Elleni on Mon Dec 30, 2019 11:48 pm; edited 1 time in total

----------

## sabayonino

Hi. Thanks for reporting 

Looking for your wifi card/adapters :

https://wiki.gentoo.org/wiki/AC1200_Wireless_Adapters

I'll check kernel-config

see /usr/local/bin/kernel.sh script to recompile the kernel  (a very tiny bash script ...) with all modules supports

----------

## Elleni

I would be surprised if it works with kernel drivers, but I know it does with rtl8812au_aircrack-ng from pentoo overlay, so if you could tell me why the successfully compiled package does not load? The obvious difference is -x86_64 suffix in /lib/modules/kernelversion path, and I don't know, where this is comming from? I'll check the mentioned script, thanks  :Smile: Last edited by Elleni on Mon Dec 30, 2019 9:44 pm; edited 1 time in total

----------

## NeddySeagoon

Elleni,

As a workaround meanwhile, try 

```
insmod /full/pathlto/module.ko
```

modprobe is shiny and well behaved. It tries to to the right thing.

insmod is a blunt instrument. It tries to do what you tell it. Its not shiny and well behaved.

If your module needs other modules loaded, modprobe takes care of this.

With insmod, loading all the bits in the right order is your problem.

----------

## Elleni

Hi Neddy, thanks, I'll test the workaround as soon as possible. Do you happen to know, what this suffix is about? On my gentoo box, I dont have it, although it is a 64-bit installation.

----------

## Elleni

Trying with insmod I get

```
insmod: ERROR: could not insert module /lib/modules/4.19.86-gentoo/misc/88XXau.ko: Invalid module format
```

 Tried all different versions now, 5.3.4, 5.2.20 and even 9999 ebuild.

----------

## NeddySeagoon

Elleni,

/lib/modules/<dir> should be named for 

```
uname -r
```

Thats how the kernel finds its own modules.

If a local version is defined in the kernel .config then that's appended to the stuff at the top of the Makefile to make uname -r.

Here be dragons. The kernel works with a local version is defined in the kernel .config but not all external kernel modules respect the local version.

This causes the situation that you report.

If that's the cause, the kernel will reject your module as the versions won't match. 

I think insmod has a -f (for force) option but its years since I've needed insmod.

dmesg is the best place to look for errors.

----------

## sabayonino

from https://github.com/pentoo/pentoo-overlay/blob/master/net-wireless/rtl8812au_aircrack-ng/rtl8812au_aircrack-ng-5.3.4_p20191030.ebuild

```
DEPEND="!!net-wireless/rtl8812au_astsam

   !!net-wireless/rtl8812au

   !!net-wireless/rtl8812au_asus"

```

https://github.com/pentoo/pentoo-overlay/tree/master/net-wireless

or this driver is not compatible with 4.19.x kernel

----------

## Elleni

I understand. Here is the corresponding dmesg after trying to load with -f (only tried within chroot for now): 

```
[   39.653965] ------------[ cut here ]------------

[   39.653974] WARNING: CPU: 4 PID: 4225 at net/wireless/nl80211.c:3153 nl80211_send_chandef+0x146/0x160

[   39.653975] Modules linked in: xfs fuse uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videodev videobuf2_common 88XXau(O) bnep amdgpu mfd_core gpu_sched ttm

[   39.653988] CPU: 4 PID: 4225 Comm: RTW_CMD_THREAD Tainted: G           O      5.4.6-gentoo #2

[   39.653989] Hardware name: System manufacturer System Product Name/PRIME B350-PLUS, BIOS 4207 12/07/2018

[   39.653993] RIP: 0010:nl80211_send_chandef+0x146/0x160

[   39.653996] Code: 00 00 be a1 00 00 00 48 89 ef 89 44 24 04 e8 f1 70 b0 ff 85 c0 0f 84 7b ff ff ff 41 bc 97 ff ff ff e9 70 ff ff ff 31 c0 eb a7 <0f> 0b 41 bc ea ff ff ff e9 5f ff ff ff e8 f8 55 76 ff 0f 1f 84 00

[   39.653997] RSP: 0018:ffffc90002c0bd80 EFLAGS: 00010246

[   39.653999] RAX: 0000000000000000 RBX: ffffc90002c0be08 RCX: 0000000000001464

[   39.654000] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffc90002c0be08

[   39.654002] RBP: ffff888408dc2900 R08: 0000000000000000 R09: ffff8883ddd5801c

[   39.654004] R10: 0000000000000016 R11: ffff88840d355ec0 R12: ffffc90002c0be08

[   39.654005] R13: 0000000000000000 R14: ffff888408dc2900 R15: ffff8883ddd58014

[   39.654007] FS:  0000000000000000(0000) GS:ffff88840ed00000(0000) knlGS:0000000000000000

[   39.654009] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033

[   39.654011] CR2: 00007f0a4b9831c0 CR3: 000000040bc44000 CR4: 00000000003406e0

[   39.654012] Call Trace:

[   39.654019]  nl80211_ch_switch_notify.constprop.0+0xc7/0x160

[   39.654077]  rtw_cfg80211_ch_switch_notify+0x142/0x151 [88XXau]

[   39.654120]  ? rtw_chk_start_clnt_join+0x7f/0x7f [88XXau]

[   39.654159]  rtw_chk_start_clnt_join+0x78/0x7f [88XXau]

[   39.654200]  join_cmd_hdl+0x273/0x37f [88XXau]

[   39.654229]  rtw_cmd_thread+0x292/0x3ed [88XXau]

[   39.654234]  kthread+0xfb/0x130

[   39.654263]  ? rtw_stop_cmd_thread+0x34/0x34 [88XXau]

[   39.654266]  ? kthread_park+0x80/0x80

[   39.654270]  ret_from_fork+0x22/0x40

[   39.654273] ---[ end trace f0db65a6700fc7bc ]---

[   53.521872] xfs filesystem being mounted at /mnt/usb supports timestamps until 2038 (0x7fffffff)

[  426.671347] 88XXau: version magic '4.19.86-gentoo SMP preempt mod_unload ' should be '5.4.6-gentoo SMP preempt mod_unload '
```

 I'll boot to the stick and try from there and post corresponding dmesg

----------

## sabayonino

as I wrote 4.19.X is not supported by the driver

 [  426.671347] 88XXau: version magic '4.19.86-gentoo SMP preempt mod_unload ' should be '5.4.6-gentoo SMP preempt mod_unload '

----------

## NeddySeagoon

Elleni,

insmod gave it a good shot but you can't load a module built for one kernel version into a completely different version.

----------

## sabayonino

You can install and build 5.x.x kernel version you need.  You can manage LRS as Gentoo Linux Installation

this is the genkernel options passed

```
genkernel --firmware --busybox --mdadm --do-keymap-auto --luks --lvm --nfs --bootdir=/boot --no-symlink --all-ramdisk-modules --install --kernel-config=/etc/kernels/config --menuconfig all
```

(or run /usr/local/bin/kernel.sh)

for better support,  most common modules are included. Feel free to remove the modules you don't need   :Rolling Eyes: 

Keep in mind that high I/O  write access could stress your USB Pendrive

----------

## Elleni

Back. Here are the corresponding dmesg entries. 

for 5.2.20 ebuild

for 5.3.4 ebuild

I'll happily try a newer kernel, but I know, it should start as it did on my hostsystem too, even before I had a 5.x kernel installed. The error before was because I had tried modprobe and insmod from within chroot.   :Wink: 

If I understand correctly -x86_64 is defined somewhere in .config? I'll check.

----------

## Elleni

Indeed localversion is where this suffix is set, as you said Neddy. 

I had tried compiling the kernel by just extracting the config from /proc/config.cz and issuing make and make modules_install without genkernel, as I was not used to it. I will now try again, but this time with the instructions sabayonino gave me and remove this lovalversion variable within menuconfig and report back, if it then works. Thanks for your assistance much appreciated, guys!

----------

## Elleni

Its a bit strange, but it works now. Writing this from LRS  :Very Happy: . As said, I compiled kernel with instructions of sabayonino and within menuconfig I deleted said suffix in CONFIG_LOCALVERSION. Now after new boot 88XXau module is successfully loaded. But if I look into /usr/src/linux/.config or make menuconfig, I see

```
CONFIG_LOCALVERSION="-x86_64"

# CONFIG_LOCALVERSION_AUTO is not set
```

also 

```
uname -r

4.19.86-gentoo-x86_64
```

So my change in make menuconfig was obviously ignored? 

Extracting config with zcat /proc/config.gz showing CONFIG_LOCALVERSION="-x86_64"

But compiling the kernel with kernel.sh obviously helped, as checking the location of the module 88XXau.ko this time it is also found in the right place

```
ls /lib/modules/4.19.86-gentoo-x86_64/misc/

88XXau.ko
```

However - I will maybe re-flash the image to start with a clean state just in case I messed something while trying to compile the kernel, as I do it on my gentoo installed box, by issuing emerge gentoo-sources && make clean && make && make modules_install & make install && grub-mkconfig.... 

-> solved. Thanks again you 2  :Very Happy: 

----------

## NeddySeagoon

Elleni,

As well as matching 'uname -r' everywhere you need the kernel and all its modules compiled with the same version of gcc. The kernel checks.

There are a few other constrains on out of kernel modules too but most of these are fixed by having the kernel .config that you want to load the kernel into to hand.

----------

## Elleni

Thanks NeddySeagoon for your detailed information. You would have made a great teacher. It's always a good oportunity to learn thus good to have you assisting in a thread - teaching howto fisch and not just feeding.  :Very Happy:  I reflashed LRS and thus recompiled kernel and rtl8812au_aircrack-ng, and this time all went well. 

One thing, I dont quite understand is, why changes made in menuconfig while in the process of compiling the kernel with genkernel within LRS are ignored. like when I had removed CONFIG_LOCALVERSION="-x86_64" from the kernel configuration. Another is - as asked in the other thread, how autologin with no password is handeled and thus could be modified, as I'd like to have the ability to boot LRS from my stick without autologin, but with normal user authentication and also a root protected with password. But even if I set a password with passwd, there is no password needed to su into root after a reboot. Furthermore it would make probably sense to encrypt the whole thing. Only then it would be wise to put on personal data on the stick, right?

----------

## sabayonino

 *Elleni wrote:*   

> Thanks NeddySeagoon for your detailed information. You would have made a great teacher. It's always a good oportunity to learn thus good to have you assisting in a thread - teaching howto fisch and not just feeding.  I reflashed LRS and thus recompiled kernel and rtl8812au_aircrack-ng, and this time all went well. 
> 
> One thing, I dont quite understand is, why changes made in menuconfig while in the process of compiling the kernel with genkernel within LRS are ignored. like when I had removed CONFIG_LOCALVERSION="-x86_64" from the kernel configuration. Another is - as asked in the other thread, how autologin with no password is handeled and thus could be modified, as I'd like to have the ability to boot LRS from my stick without autologin, but with normal user authentication and also a root protected with password. But even if I set a password with passwd, there is no password needed to su into root after a reboot. Furthermore it would make probably sense to encrypt the whole thing. Only then it would be wise to put on personal data on the stick, right?

 

I'll check this asap. Thanks for your help.

Some kernel features should be disable/enable ... 

All kernel configurations are stored in /etc/kernels dir. 

Genkernel autosave your configuration all the time you (re)compile the kernel.

Anyway , please check /etc/genkernel.conf to setup your favourite configuration/options to pass to genkernel

Root by default can't start any X11 applications

Root autologin cofigured by /etc/inittab

```
[...]# TERMINALS

#x1:12345:respawn:/sbin/agetty 38400 console linux

c1:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty1 linux

c2:2345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty2 linux

c3:2345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty3 linux

c4:2345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty4 linux

c5:2345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty5 linux

c6:2345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty6 linux

```

"Welcome message"  to TTY and some checks is provided by /bin/bashlogin file

/etc/inittab.bk is a backupfile of original Gentoo inittab file.

```
cp /etc/inittab.bk /etc/inittab
```

You'll get the standard Gentoo login to TTY.

Root account is passwordless. Please setup the Rott password before any changes.

Then you can setup your user as Gentoo handbook explained.

You can remove "Keyboard Menu selection" to grub :

```
# chmod -x /etc/grub.d/ 42_localeset && grub-mkconfig -o /boot/grub/grub.cfg
```

Setup keyboard configuration according on Gentoo Handbook.

See /etc/default/grub --> keymap=\${bkeymap} kernel line option also (remove this and update grub.cfg)

--dokeymap option to genkernel must be removed and future kernels must be configured without this option to avoid keyboard selction at all boot time

LRS is not localized. If you want to localized your LRS installation , plese follollow Gentoo Handbook Localization Guide. 

You can rebuild all LRS system and customize all LRS configuration files !!! It's Gentoo !!

LRS was build in my spare time as funny work ! Nice to share LRS with you ! I'm not a programmer or developers !

Just for fun !

----------

## Elleni

Thanks sabayonino, for your help and for sharing your work. Very nice  :Smile: 

----------

## sabayonino

20200103 images are available . Keymap setup at boot will be persistent after first system boot and CONFIG_LOCALVERSION was disabled.

Please let me know if it works.

----------

## Elleni

Yep, works fine! Thanks and keep up the good work!   :Very Happy: 

----------

