# How do you compile your Linux kernel without breaking boot?

> Compiling your Linux kernel shrinks the attack surface and speeds up boot. A tool does it without root and without leaving you without a system if it fails.
> By José Maldonado · Technology · 2026-11-09

Compiling your own kernel has gone from a rite of passage to a decision with numbers behind it. A generic distribution config drags in thousands of drivers your machine will never load, and each one is surface you don't use but that is still there. The project [personal-kernel-builder](https://github.com/yukiteruamano/personal-kernel-builder) takes that idea to its practical extreme: it starts from a config reduced to a specific laptop and goes from about 3,450 module options to about 440, a reduction of roughly 90%, without losing functionality.

The interesting part is not the trimming, but how it avoids the two classic accidents of this task. The first is compiling as root, which turns any error into a problem for the entire system. The second is being left without boot because you replaced the kernel you were using. The tool solves both with a strict separation of permissions and with an explicit refusal to overwrite the running kernel.

The trade-off exists and is worth knowing before you start: this method is designed for Slackware, and its module signing design closes the door to any driver that does not come from the kernel tree. If you depend on NVIDIA's proprietary driver or on modules that recompile themselves after every update, this guide helps you understand the method, not adopt the tool as is.

## What do you gain and what do you lose by compiling your own kernel?

The immediate gain is attack surface. A kernel that only knows your chipset, your disk and your network card cannot load a driver for hardware you do not have, which reduces the vulnerabilities that affect you. The second gain is boot time and memory: fewer modules to probe means less work on the critical path.

Therein lies the part that decides adoption: a given machine has a specific hardware set, and everything else is surplus. The real work consists of distinguishing what your equipment needs to reach the desktop from what it will never use.

The cost is concrete too. Every kernel security update stops arriving on its own and comes to depend on you recompiling. And reproducibility breaks if you do not save the config. After all, six months from now you will not remember why you checked one option and not another, so you must keep everything at hand.

![A look at the personal-kernel-builder project](https://content.observatorioblockchain.com/wp-content/uploads/2026/11/persona-kernel-builder-github.webp)
*A look at the personal-kernel-builder project*

The tool tackles that second problem with a per-machine versioned configuration file and backups with retention, seven by default. It is the least flashy part of the project and the one that decides whether you compile again in a year or give up in the third week.

## Is compiling your kernel worth it in 2026?

It depends on what you're buying. If you're after measurable desktop performance, the honest answer is that the gain is usually small and hard to attribute, because the heavy lifting is done by the drivers and the scheduler, not the list of modules. If you're after control, a reduced attack surface and understanding what runs on your machine, the calculation changes. In that case, compiling the kernel lets you gain an enormous level of security. For example, the MPTCP flaw can be avoided simply if the module is not compiled. One single change, and you're protecting yourself from one of Linux's most dangerous remote bugs.

There is a third scenario where interest grows: the steady drip of kernel flaws and the difficulty of absorbing them in time. The sheer avalanche of CVEs in the kernel has itself become a management issue, as shown by the [a tally of vulnerabilities that the kernel cannot keep up with patching](https://observatorioblockchain.com/en/cybersecurity/kernel-linux-avalancha-cve-triaje-ia/)Whoever compiles their kernel decides which version runs and when it updates, and that is a security decision as well as a technical one.

## What do you need before you start?

The tool installs as a Slackware package, although you can use it on any other distro, and it works on the source tree that the distribution already maintains on the system. Before touching anything, check that you have space, that you know which kernel is currently booting and that you keep a GRUB entry you can return to. The following table summarizes the minimum you can start with.

Requirement

Detail

Why it matters

Base distribution

Slackware with \`kernel-source\` installed

The build starts from \`/usr/src/linux\`

Build user

An unprivileged account, defined with \`–builder\`

It is the one that compiles and owns the config

Root access

Only for \`init\`, \`install\`, \`uninstall\` and \`adopt\`

Install and remove boot entries

Space in \`/tmp\`

Enough for a full copy of the sources

The build takes place in a private copy

Fallback kernel

A GRUB entry that works

The safety net if the new one does not boot

WSL or initrd version

\`USE\_INITRD=no\` by default, or \`–initrd\`

Changes which drivers are compiled in

The builder user detail is not cosmetic. All the heavy work happens in a copy of the sources inside \`/tmp/personal-kernel-builder-<user>\`, a directory that a reboot wipes. That copy belongs to the user, not root, and that is where the first half of the protection lies.

## The five-step method

Order matters more than haste, and there is one step the tool refuses to do for you. This sequence follows the flow documented by the project, with the package installation already done.

1.  As root, initialize the profile with a name and the user who will build: \`personal-kernel-builder init –name name –builder user –config seed/config-machine\`. That \`–config\` can be the repository's example config or one of your own.
2.  As the builder user, adapt the config to the installed source version with \`personal-kernel-builder config olddefconfig\`. That way the new options in the version are resolved without dragging along those from a previous kernel.
3.  Run \`personal-kernel-builder check\` and then \`build\`, which compiles, signs the modules and replaces the version suffix with the name you chose. This is where the result appears in the form of your own kernel.
4.  As root and before rebooting, run \`install\`, which only copies the build already prepared and sets the default GRUB entry. Root does not run the compilation at any point.
5.  Boot the new kernel and run \`verify\`. If the check passes and the system behaves, remove the old kernel with \`uninstall\` so as not to pile up entries.

Step four is the one that gains most from the separation of permissions. Installing is an act of root, but compiling is not, and the project deliberately keeps it that way: root never runs \`make\` on a user's tree.

## How to trim the config to your hardware?

Trimming is not about turning things off until it boots. It is about knowing what your machine needs to reach the desktop and keeping that inside the kernel, instead of trusting that it will load in time. The project formalizes that distinction with two lists in its configuration file: the options without which the machine will not boot and the modules that verification must find afterwards.

The ThinkPad example illustrates the criterion. For the disk and the file system, the options are compiled in (\`BLK\_DEV\_NVME=y\`, \`XFS\_FS=y\`), not as a module. For graphics and network, the module is enough. And laptop support comes in through specific routes: \`THINKPAD\_ACPI\`, \`AMD\_PMC\`, \`X86\_AMD\_PSTATE=y\` and the \`TYPEC\_UCSI\` and \`UCSI\_ACPI\` set for USB-C.

The verification list has a detail that saves false diagnoses: \`amd\_pmc\` only loads when the BIOS suspend state is set to "Windows and Linux", that is, s0ix. If your machine uses S3, verification skips it instead of flagging a failure that does not exist. The same goes for the battery, which is checked only if the machine has one.

To start from your own configuration rather than the repository's, the tool offers a \`diff\` against the config that \`/boot/config\` is pointing to. It is the fastest way to see what you have changed and to reconstruct the reasoning months later.

## Signing the modules

Here is the design decision with the most consequences. Each build generates its own key, signs the modules and deletes the private key when it finishes. With mandatory signing enabled, the kernel only accepts modules signed with that key, and since the key no longer exists, no one else can sign anything for that kernel.

The benefit is that a foreign module cannot slip into your kernel. The price is that the one you did want cannot get in either: out-of-tree drivers are excluded by definition. If your machine needs one of them, this method is not for you, and it is better to find that out before compiling than after rebooting.

The same decision explains the refusal to replace the running kernel. Installing a new build on top of the one running would leave the system unable to load any module until reboot, because the key changed. The tool rejects the operation and forces you to boot from another kernel first, or to force the replacement and reboot immediately.

## Booting without initrd, the part that breaks boots

With the default value, the kernel boots without an intermediate image. That means the root disk and file system drivers have to be compiled in, and that GRUB cannot look up the disk by identifier. The tool handles the second with an installation option that disables the use of UUIDs, but the first is your config's responsibility.

If you prefer the traditional route, installing with \`–initrd\` generates the intermediate image for the root file system type. It is still more fragile than direct booting when you change hardware, because the image has to be regenerated, but it is the conservative option if your machine has particularities.

### What if the new kernel does not boot?

The short answer is to have another GRUB entry before you start, and the tool is built assuming you do. The distribution kernel stays in the menu, and installation adds the new one without removing the previous one. Removing the old one is a separate, later act that you should only carry out once the new one has been working for a while.

There is a second, quieter scenario: it boots but something does not work. It is usually a missing module or an option that should be compiled into the kernel. The project's verification and the diff against the reference config tell you what changed.

## What this method does not give you and why it matters

It is worth saying plainly: this is not a universal guide to compiling kernels. The tool is for Slackware and its packaging reflects that, so anyone using Arch, Debian or Fedora will apply the method with their own tooling and without these conveniences. What carries over is three ideas: compiling without root, not overwriting the running kernel and setting down in writing which options your machine needs.

That last point survives a change of distribution. A commented and versioned config is worth more than a script, because it explains decisions that in a year no one remembers. Anyone who has read the [roundup of what went into Linux 7.3 for graphics and scheduling](https://observatorioblockchain.com/en/technology/igalia-linux-7-3-v3d-sched-ext-amdgpu/) knows that the kernel changes enough every few months for memory to fail.

And anyone who has followed the [case of the module that unlocked tensor cores on an RTX 4090](https://observatorioblockchain.com/en/technology/rtx-4090-tensor-cores-modulo-kernel/) understands the other end of the problem: an out-of-tree module can give you something the official kernel does not offer, and this method forbids it by design. There is no good answer for everyone, only an informed decision about what you prefer to control and what you prefer to delegate.
