I have a simple "hello world" Linux kernel module that I would like to compile for a different host. My host is on a 5.x kernel version and the target is on 4.x.
I do not want to update the kernel versions. This is a virtualized lab environment for testing purposes.
When the target kernel version's headers are in the repos, this is a straightforward task. All it usually takes is an apt install linux-headers-$(uname -r)
or similar, followed by make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
. It doesn't seem so easy otherwise.
Even when attempting to download header packages manually from the Debian archive I'm met with dependency issues with older binaries that I do not want to overwrite my up-to-date binaries with. I have even tried to compile against the full Linux kernel source and have similar issues.
I have no experience building kernel modules except for simple ones using my own kernel's headers. Any help?