I am writing this on a kernel called 7.3.4-stargate. It comes from a small set of bash scripts that I keep in a repository named stargate-kernel: one command takes the latest stable release from kernel.org and turns it into Debian packages built for this laptop.
The laptop is a TUXEDO InfinityBook Pro AMD Gen10 (Ryzen AI 9 HX 370) running Debian 13. The name, the boot logo and the build user in /proc/version (jack_oneill) are there because I am a Stargate SG-1 fan.
The code is at codeberg.org/squidd/stargate-kernel, GPL-2.0-only like the kernel itself.

The boot logo of the kernel, logo/stargate-logo.png in the repository.
One command
./build-optimized-kernel.sh # latest stable; exits early if it is already installed/running
FORCE=1 ./build-optimized-kernel.sh # rebuild the same version (after changing the script)
CHANNEL=mainline ./build-optimized-kernel.sh # current -rc from git.kernel.org (unsigned tarball)
CONFIG_ONLY=1 ./build-optimized-kernel.sh # stop once .config is ready, no compile
There are no arguments. Every choice is an environment variable with a default, and the README has the table.
In order, the script:
- Reads
releases.jsonfrom kernel.org and picks the latest stable version. If that version is already installed or running, it stops. - Prints the commit subjects of every stable release since the running kernel, from the kernel.org ChangeLog files.
- Downloads the tarball and checks its PGP signature. Stable tarballs are signed by Greg Kroah-Hartman, and the signature covers the uncompressed
.tar, so the script pipesunxz -cintogpg --verifyand never writes that 1.6 GB file to disk. - Configures the kernel (the long part, below).
- Builds
linux-imageandlinux-headerspackages withbindeb-pkg, the kernel’s own make target for Debian packages. - Asks whether to install them: headers first, then the image, because the image’s post-install step triggers DKMS and DKMS needs the headers.
It never touches the running kernel. The packages add a GRUB entry, and the previous kernel stays in the menu as a fallback.
What differs from the Debian kernel
The left column is read from the config of the kernel I am running. The right column is from Debian’s kernel packaging repository, because no Debian kernel is installed on this laptop any more.
| Area | stargate | Debian |
|---|---|---|
| CPU target | CONFIG_X86_NATIVE_CPU=y, which builds with -march=native | generic x86-64 |
| Modules | only what was loaded at build time, plus two keep lists | almost everything, as modules |
| Timer tick | HZ=1000 | HZ=250 |
| Default TCP congestion control | BBR | CUBIC (BBR is a module) |
| UBSAN | off | on (bounds and shift checks) |
| Boot logo | CONFIG_LOGO=y with my own image | not set |
NTSYNC (/dev/ntsync, used by Wine and Proton) | built in | module |
A few notes on these.
CONFIG_X86_NATIVE_CPU has been in the vanilla kernel since 6.16. Before using it, the script passed -march through KCFLAGS, and it still does when I ask for a specific target.
HZ=1000 means the timer interrupt fires every millisecond on a busy CPU, where Debian’s 250 means every four.
BBR changes how this machine sends TCP data: it estimates bandwidth and round-trip time, where CUBIC reacts to packet loss. It does nothing for downloads.
The script also puts BFQ back as a module, because the trimming step drops it. Debian ships it as a module too, so it is not in the table. On this laptop the NVMe disks run with the scheduler set to none, and the BFQ module is not even loaded.
The scheduler is the stock EEVDF. BORE, an out-of-tree patch on top of it, is opt-in with ENABLE_BORE=1 and is skipped with a warning if it does not apply to the version being built. I am not running it.
Some numbers from this machine: the kernel was built with 354 modules, and 222 are loaded right now. The image package takes about 44 MB installed. dpkg still has the record of a removed Debian 6.12 image at about 108 MB, which is a different kernel series, so take it as an order of magnitude.
localmodconfig, and everything it broke
The trimming is done by make localmodconfig. It looks at the modules loaded at that moment and turns off every other module. That makes the build short and the kernel small. It also means that anything not plugged in while the script runs is gone from the next kernel.
The git history is mostly a list of how I found that out:
- A Bluetooth keyboard and mouse showed as connected and typed nothing. BlueZ creates their input device through
/dev/uhid, andCONFIG_UHIDwas gone. mount -o loopon an ISO failed with “failed to setup loop device”. No loop driver.- TUXEDO’s DKMS drivers did not build at all without
CONFIG_IIO. - Proton VPN’s kill switch could not connect: it creates dummy network interfaces, and
CONFIG_DUMMYwas gone. - The CH340 cable I use to program a Baofeng radio, and a u-blox USB GPS, lost their serial drivers.
The first answer was KEEP_MODULES, a list of symbols forced back as modules. After the third breakage I added KEEP_FAMILIES: whole Kconfig prefixes (HID, input, Bluetooth, USB serial, gamepads, Type-C, USB audio) restored from the stock Debian config. On 7.2.7 that brought back 357 of 366 options, about 260 small modules.
Then that broke too. Once the last Debian kernel was removed, there was no Debian config left to copy from, and the step was skipped, with only a warning in the log. Now it falls back to the running kernel’s own config, which can only return what the previous build already had. The last two commits, from last week, add the radio cable and the GPS back by name. The radio cable is already in the kernel I am running; the GPS driver arrives with the next build. The whole config difference between my 7.3.3 and 7.3.4 is one line: CONFIG_USB_SERIAL_CH341=m.
Checking that the config landed
scripts/config writes any symbol name you give it, and make olddefconfig then discards the ones that do not exist, without a word. I lost BFQ that way: the symbol is IOSCHED_BFQ, not MQ_IOSCHED_BFQ. The default congestion control was the same story: DEFAULT_TCP_CONG is derived from a choice, and the option to set is DEFAULT_BBR.
So after configuring, the script greps every requested symbol back out of .config and stops the build if one is missing. It also saves the config of each successful build and prints a diff against it the next time.
The logo
With CONFIG_LOGO the framebuffer console draws one logo per CPU. This machine has 24 threads, which makes 24 Stargates. A GRUB drop-in in the repository adds fbcon=logo-count:1, together with a console color palette.
The honest limits
- One machine. Everything in the repository was written and checked on this laptop. The variables are there for other machines, but I have nothing to show that they work on one.
- I did not benchmark it. I have no numbers for speed, battery life or boot time against the Debian kernel, so I am not claiming any.
- Every release is a rebuild. Nothing arrives through
apt upgrade: when kernel.org publishes a stable release, I run the script. The README says about 8 minutes cold on 24 threads and 2 to 3 with a warm ccache. I did not time it again for this post. - DKMS. The TUXEDO drivers are out-of-tree modules and are rebuilt for every kernel. The script only offers to purge older kernels when DKMS reports every module as installed. With
CHANNEL=mainlinethey may not build yet. - Secure Boot. The packages are unsigned. Secure Boot is disabled here; with it on, you need your own signing setup.
- The signature check warns and goes on. If the PGP verification fails, the script prints a warning and builds anyway. The
-rctarballs have no signature at all. - The fallback is my own kernel. The other GRUB entry is the previous stargate build, with the same trimmed config.
If you try it on different hardware, I would like to know what localmodconfig took away from you. Issues are open on Codeberg.