Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make building custom kernel modules easier #370

Open
hvenev opened this issue Dec 18, 2017 · 1 comment
Open

Make building custom kernel modules easier #370

hvenev opened this issue Dec 18, 2017 · 1 comment

Comments

@hvenev
Copy link

hvenev commented Dec 18, 2017

The whole uncompressed kernel source is more than 700 MB, and extracting it takes a while. We can do something similar to what is done in distributions like Debian and Fedora.

The idea is to take all headers, the config, and a few build results from make prepare modules_prepare. The resulting directory is much smaller. I successfully built wireguard using dkms on x86_64 using a 52 MB directory created by the following script:

arch=x86_64
asmarch=x86
release=...
upstream="${release%%-*}"
local="${release#*-}"

kdir="/lib/modules/${release}"
cd /usr/src/linux

wget -O Module.symvers "http://mirror.scaleway.com/kernel/${arch}/${release}/Module.symvers"
wget -O .config "http://mirror.scaleway.com/kernel/${arch}/${release}/config"
printf 'CONFIG_LOCALVERSION="%s"\nCONFIG_CROSS_COMPILE=""\n' "${local:+-$local}" >> .config

make prepare modules_prepare

mkdir -p $kdir/build

for dir in .config Module.symvers Makefile scripts include arch/${asmarch}/include arch/${asmarch}/Makefile* arch/${asmarch}/kernel/asm-offsets.s; do
	rm -rf $kdir/build/$dir
	cp -a --parents $dir $kdir/build/
done

My suggestion is to provide a squashfs image of this. It comes down to just above 7 MB, or 15 MB together with the modules. Mounting read-write can be done using overlayfs.

@shawnl
Copy link

shawnl commented Jul 3, 2018

The kernel modules are already copied into the images automatically. This should be copied into the images as well.

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

No branches or pull requests

2 participants