The Linux kernel: building, configuring and tuning
You fetch, configure, build and boot the kernel source, and safely practise kernel parameters, module signing and writing a small module of your own.
Level 401 · 16 lessons · 15 practice labs
Lessons
Knowing the kernel
- Kernel versions, LTS and distribution kernels
- Finding your way around the source tree
- Configuration: menuconfig and localmodconfig
- Short task: interpret the difference between two kernel configs
Building
- Building, installing modules and initramfs
- Booting the new kernel and keeping a way back
- Building the kernel as a package
- Module signing and Secure Boot
- Short task: build and boot a slimmed-down kernel without unneeded drivers
Tuning
- Kernel command line parameters
- sysctl in depth: the important non-network settings
- Kernel lockdown and security parameters
- Short task: compare a server's kernel settings with the company standard
Writing a module
- A first kernel module: load, unload, log
- Module parameters and a /proc entry
- Capstone: produce, test and roll out a signed custom kernel and module, with a way back
Practice labs
- Read the running kernel's version and configuration: Find the kernel version, build date and whether three given options are built in or modules.
- Decode boot parameters and their effects: Match the kernel command line parameters against the documentation and find the one that disables a security mitigation.
- Report the state of CPU vulnerability mitigations: From the sysfs vulnerability entries extract the state of each mitigation and report in a table which is unprotected and why.
- Compare two kernel configurations: Diff the distribution kernel's configuration against the custom one and submit the number of options turned off.
- Build, install and boot a kernel with a fallback entry: Starting from the current config build the kernel, install it with modules and boot it while the old kernel stays in the menu.
- Configure a trimmed kernel for a server: Shrink the config based on the loaded modules only, turn off unused subsystems and measure the build time and size difference.
- Read the current memory settings: Read swappiness, dirty page ratios and overcommit settings and find the one that differs from default.
- Fix connection backlog overflow with kernel settings: On a server dropping connections under load find the backlog overflow counters, raise the relevant settings and show the counters stop.
- Write a workload tuning profile and measure it: Write a profile with memory, scheduler and disk settings for a database workload and prove the difference with before and after measurements.
- Build and load a first kernel module: Build the smallest module that prints a message on load and unload, load it and show the messages in the kernel log.
- Add a parameter and a /proc entry to a module: Add a load-time parameter and a /proc entry that reads it to a module, and verify the entry is cleaned up on unload.
- Sign a module and block unsigned loading: Sign a module with your own key, enforce signatures and show from the kernel log that an unsigned module is refused.
- Rebuild an out-of-tree module after a kernel update: Check the DKMS status of an out-of-tree module missing on the new kernel and get it built for that kernel.
- Clean up old kernels safely: Remove old kernels filling /boot while keeping the running and previous one, and set the retention count.
- Apply a patch to the kernel and ship it as a package: Apply a given fix patch to the source, build and package it with a version suffix, then install it on a second machine and verify boot.
About this course
You fetch, configure, build and boot the kernel source, and safely practise kernel parameters, module signing and writing a small module of your own.
What you will learn
- Knowing the kernel
- Building
- Tuning
- Writing a module
Prerequisites
You should have practised the topics of the same path up to level 301.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at level 401; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.