As always, you have the option to compile directly on an Enzian or to cross-compile.
Compiling on Enzian
The main challenge of compiling on Enzian is that we are space constrained due to the 5 GB size limit imposed by the image provided over ISCSI. Further, I recommend you do this on a named volume, so you keep your setup and the installed modules of your freshly built kernel.
Prerequisites
First, you need to install the missing dependencies to build a Linux kernel. For a normal gcc build you will need to run
...
If you want to compile a kernel with Rust, additionally set up a Rust toolchain and follow the steps in the kernel Rust Quick Start page.
Finally, you will want to clone the kernel source to your scratch directory.
Configuration
First copy the config of the running system to your kernel source directory:
...
You will at some point get an error/warning/notice that the keychain for the trusted system keys for signature checking is not found. The easiest solution is to set CONFIG_SYSTEM_TRUSTED_KEYS=""
and CONFIG_SYSTEM_REVOCATION_KEYS=""
. You can also copy the debian keychains to the system and specify a path there (see Stackoverflow).
Building and Installing
Build the kernel using make -j 47 all
(make sure to specify variables needed). If the build succeeds, you will find your compressed image in arch/arm64/boot/Image.gz
.
...
where <your kernel version>
matches the directory in /lib/modules/<your kernel version>/
.
Booting the compiled kernel
First, you need to ask an admin to create a directory for you in /srv/tftp/userkernels
on enzian-gateway
. You can then scp
the compressed image and (if nessecary) the generated initramfs from the Enzian where you built the kernel into your userkernels
directory.
...
Tip | ||
---|---|---|
| ||
If you leave the modules of the old kernel in /lib/modules/ you can edit the the boot entry in the grub menu to switch back and forth between your own kernel and the default kernel from the golden image. This is especially useful if your kernel does not boot. |
Troubleshooting
What Makefile targets do even exist?
The Linux kernel Makefile has the very helpful target make help
, which explains all available targets.
How full is the ISCSI provided disk on Enzian?
You can find out with
$ lsblk -o NAME,PATH,FSSIZE,FSAVAIL,FSUSE%,MOUNTPOINT
Why is the ISCSI provided disk on Enzian already full?
You can have a look at the space hogging directories/files using
...
If you do not wish to see your scratch space throw a grep -n "/scratch"
in front of the sort.
How do I mount a ramdisk for some additional space?
First, create a directory to mount to (e.g. /mnt/ramdisk0
) and then mount with sudo mount -t tmpfs -o size=5G ext4 <mount point>
.
When I boot my kernel I get an error "invalid magic number".
Then you did not supply the correct kernel image. Check again that you supply the compressed kernel image Image.gz
(also often renamed to vmlinuz
).
...