Skip to content

Enable kernel module support#23

Open
proan wants to merge 6 commits intoptrsr:masterfrom
proan:enable_kernel_modules
Open

Enable kernel module support#23
proan wants to merge 6 commits intoptrsr:masterfrom
proan:enable_kernel_modules

Conversation

@proan
Copy link
Contributor

@proan proan commented Jan 2, 2026

The Raspberry Pi OS and kernel support kernel modules out of the box. pi-ci builds a custom kernel to boot via qemu, but it does not build or install the accompanying kernel modules. This PR adds support for kernel modules in pi-ci.

dockerfile is modified to build the kernel modules in the same stage as the main kernel build. Modules are then "installed" to a directory in kernel-builder where it can be copied into the emulator image later. start.py uses virtfs to map the modules directory into qemu. start.py and init.py are modified to remove the redundancy of check_base_file() and to add support for copying the modules directory into a Docker volume.

From a running qemu instance, the loaded kernel modules can be checked by the lsmod command.

This PR may address some of the questions raised in #17.

@ptrsr
Copy link
Owner

ptrsr commented Jan 4, 2026

Hi @proan , thank you for this PR!

Have you tested what happens if the resulting image with the modified fstab gets loaded in a real RPi? At that point it will miss the virtfs file system with the modules.

@proan
Copy link
Contributor Author

proan commented Jan 4, 2026

Ah, I have not tested that. And I'm pretty sure it will fail as you mention. So this will work for virtual RPis only.

I'll also have to look at how export handles the kernel when exporting to a real RPi. In 'master', the /lib/modules directory is populated with stock kernel modules, so adding the ones for our custom kernel should be fine.

I see 3 options to resolve this and keep kernel modules for the virtual RPi:

  1. (Manual load) Remove the line from fstab and manually mount the directory. This is how I was doing it until I updated fstab
  2. Modify the export functionality to remove the problematic line from fstab before writing the image to disk.
  3. I'll have to learn more about what the guestfish lines in the dockerfile are doing, and modify them or add another to copy the kernel modules into /lib/modules.

@proan
Copy link
Contributor Author

proan commented Jan 4, 2026

  1. Set fstab to skip over that mount if it's not there: https://askubuntu.com/questions/14365/mount-an-external-drive-at-boot-time-only-if-it-is-plugged-in

I will look into the export more to learn how the kernel is handled before I offer my own preference. I'm happy to take others' input though.

@ptrsr
Copy link
Owner

ptrsr commented Jan 4, 2026

Option 4 seems the most reasonable. Adding the nofail to the fstab entries and testing the resulting behavior on a real RPi. If you could confirm this, I'll do a final test and merge this.

@proan
Copy link
Contributor Author

proan commented Jan 4, 2026

I'll test with a real RPi tomorrow.

@proan
Copy link
Contributor Author

proan commented Jan 5, 2026

I updated fstab as discussed to add nofail. I tested on a RPi 3B and was able to boot the image. I tested both "flash" and "export" functionality, and both worked.

In the real RPi, the kernel and modules showed 6.6.51 and in the virtual RPi, the kernel and modules are 6.6.78. I compared the output of lsmod, and the real RPi loads significantly more modules than the virtual RPi. However, both systems find and load modules.

@ptrsr
Copy link
Owner

ptrsr commented Jan 6, 2026

fantastic, I'll test it soon on a Pi 5 and merge once completed. Aiming to release version 1.6 with your changes in the coming week.

@proan
Copy link
Contributor Author

proan commented Jan 9, 2026

I am working on the option to enable GUI support, but that 1. depends on this branch, and 2. is not ready yet, as I need to simplify launching the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants