LinuxCommandLibrary

genkernel

Build an initial RAM disk and kernel

TLDR

Automatically compile and install a generic kernel

$ sudo genkernel all
copy

Build and install the bzImage|initramfs|kernel|ramdisk only
$ sudo genkernel [bzImage|initramfs|kernel|ramdisk]
copy

Apply changes to the kernel configuration before compiling and installing
$ sudo genkernel --menuconfig all
copy

Generate a kernel with a custom name
$ sudo genkernel --kernname=[custom_name] all
copy

Use a kernel source outside the default directory /usr/src/linux
$ sudo genkernel --kerneldir=[path/to/directory] all
copy

SYNOPSIS

genkernel [options] [all|--kernel|--initramfs|--install]

PARAMETERS

--all
    Builds both the kernel and the initramfs, and optionally installs them.

--kernel
    Builds only the kernel.

--initramfs
    Builds only the initramfs.

--install
    Installs the kernel and initramfs to the boot partition. Requires root privileges.

--menuconfig
    Runs `make menuconfig` to allow interactive kernel configuration.

--xconfig
    Runs `make xconfig` to allow interactive kernel configuration using a graphical interface (if available).

--oldconfig
    Runs `make oldconfig` to update the kernel configuration based on an existing .config file.

--no-clean
    Skips the `make clean` step before building the kernel.

--no-mrproper
    Skips the `make mrproper` step before building the kernel.

--config=
    Specifies the kernel configuration file to use.

--modules=
    Specifies a list of modules to include in the initramfs. Modules can be all, dep, or a space seperated list of modules.

--loglevel=
    Sets the log level for the build process (e.g., 0 for quiet, 7 for maximum verbosity).

--help
    Displays the help message.

DESCRIPTION

genkernel is a utility designed to automate the process of building a Linux kernel and creating an initial RAM disk (initramfs). It simplifies kernel configuration, compilation, module management, and initramfs generation, making it easier for users, particularly those with limited experience in kernel building, to create a bootable system. The primary goal is to handle most of the complexity involved in kernel building, allowing users to focus on other aspects of system configuration. genkernel supports various hardware configurations and boot methods, providing flexibility for different use cases.
It is often used in distributions like Gentoo Linux where manual kernel configuration is common, offering a more streamlined approach. The tool automates steps like kernel configuration, module discovery, dependency resolution, and initramfs creation that could otherwise be time-consuming and error-prone if done manually. genkernel does not aim to replace the flexibility of full manual configuration; rather it provides a robust and user-friendly automated alternative.

CAVEATS

Requires a properly configured kernel source tree. Root privileges are necessary for installation. The generated initramfs might not be suitable for all systems and may require customization. Using with custom kernel configurations can lead to unexpected results if not configured correctly.

CONFIGURATION FILES

genkernel uses a configuration file (typically /etc/genkernel.conf or /etc/genkernel/main.conf) to control its behavior. This file allows users to customize various aspects of the kernel build process, such as the kernel version, module settings, and initramfs options. Consult the genkernel.conf man page for more details.

BOOTLOADER INTEGRATION

After building the kernel and initramfs, genkernel can assist with updating the bootloader configuration (e.g., GRUB or LILO). This ensures that the system can boot into the newly built kernel. Consult your distribution's documentation for specific bootloader instructions.

HISTORY

genkernel emerged as a response to the complexities of manually configuring and building Linux kernels, particularly within the Gentoo Linux community. Early versions focused on automating the basic steps of kernel compilation and initramfs creation. Over time, it has evolved to support more advanced features, such as module management and integration with various bootloaders. The goal has always been to provide a simple and reliable method for building kernels, reducing the barrier to entry for users who are not kernel experts. Development continues to focus on improving automation, expanding hardware support, and enhancing the user experience.
genkernel is still in active usage in the Gentoo community and other distributions, where users wants a balance between automated kernel building and fine-grained manual control.

SEE ALSO

make(1), mkinitrd(8), dracut(8)

Copied to clipboard