autokernel icon indicating copy to clipboard operation
autokernel copied to clipboard

A tool for managing your kernel configuration that guarantees semantic correctness

ATTENTION! A dependency of autokernel (Kconfiglib) unfortunately seems to be abandoned. It is an integral part of this tool but unfortunately I don't have the time to take on a project of that size myself. At some point in the future, this project will be rewritten without said dependency. Until then: Proceed with care.



autokernel

Quick start guide | Documentation | Gitter Chat

PyPI MIT License Docs Gitter

About autokernel

Autokernel is primarily a kernel configuration management tool. Its main purpose is to generate a kernel .config file from a more formal description of your configuration. To help you writing the configuration, it comes with some helpful features:

  • Detect kernel options for your system (based on information from /sys)
  • Manage the kernel configuration in a more structured and sane way. Option conflict detection and conditional expressions for configuration statements allow writing a sound and modular configuration that can be used with multiple kernel versions.
  • Build the kernel (and initramfs) and install them on the system

You may use it for any combination of the above, There is no need to use it as a build system if you only want to detect options for your device. Please have a look at the Introduction section from the documentation, which explains more about what this tool is designed for, and how it works.

Short examples

This is a short example config that can be used to build a (almost) defconfig kernel, without an initramfs. This style of configuration allows deterministic builds and provides a way of clearly stating your configuration and intentions. Have a look at the documentation to see equally simple examples which allow you to generate and integrate an initramfs into your kernel.

module base {
	# Begin with the kernel defconfig
	merge "{KERNEL_DIR}/arch/{ARCH}/configs/{UNAME_ARCH}_defconfig";

	# Enable expert options
	set EXPERT y;
	# Enable 32-bit emulation
	set IA32_EMULATION y;
}

kernel {
	use base;

 	# Enable efi
	set EFI y;
	set EFI_STUB y;
	set EFIVAR_FS y;

	# Set initramfs (genkernel) keymap
	add_cmdline "keymap=de";
}
Detecting kernel options Automatically satisfying a kernel option
asciicast asciicast

Quick start

To get started right away, please check out the Quick start guide. For in-depth command explanations, visit the Usage section.

Installation

You can use pip to install autokernel, or run from source:

pip

pip install autokernel

From source

git clone "https://github.com/oddlama/autokernel.git"
cd autokernel
pip install -r requirements.txt
./bin/autokernel.py --help

Afterwards you should run autokernel setup once to create a default configuration in /etc/autokernel.

Kernel hardening

A special note if you are interested in hardening your kernel: Be aware that autokernel provides a preconfigured module for kernel hardening (hardening.conf), which is compatible with any kernel version >= 4.0. Every choice is also fully documented and explanined. Feel free to adjust it to your needs.

Acknowledgements

I would like to especially thank the following projects and people behind them:

  • kconfiglib for the awesome python library to load and process Kconfig files, whithout which this project would have been impossible.
  • sympy for the sophisitcated symbolic logic solver
  • lark for the great parsing library
  • LKDDb for providing the awesome Linux Kernel Driver Database (which is used for option detection)
  • KSSP for the great list of kernel hardening options
  • CLIP OS for their well documented and well chosen kernel options
  • kconfig-hardened-check for the collection of options from several kernel hardening resources