You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to build kernel in Kan-Linux for unrecognized hardware on your laptop or PC
#34
This doc describes how to build a customized kernel to adapt to your PC or laptop’s hardware on installed Kan-Linux.
kan-linux aims to support common consumer PC and laptop hardware out of the box. When a device on your machine is not recognized (no WiFi interface, no sound card, unknown PCI device in lspci), you can usually fix it yourself by enabling the right driver and rebuilding the kernel. This guide walks through the full process.
It is written for both humans and AI agents. Every step is deterministic: the inputs are your hardware, the running kernel config, and the kernel source tree.
1. Identify the hardware
lspci -nn # PCI devices with vendor:device IDs (sound, WiFi, Ethernet, GPU, ...)
lsusb # USB devices
dmesg | grep -iE "error|fail|unknown"| head -40
lsmod # which drivers are currently loaded
The vendor:device ID from lspci -nn (e.g. [8086:51ca]) is the key. You will
use it later to confirm which kernel driver claims the device.
2. Check the running kernel configuration
kan-linux ships the running kernel's configuration at /proc/config.gz:
zcat /proc/config.gz | grep -i <keyword>
This is the ground truth of what is actually built into your kernel. Use it to
answer: "is the driver I need enabled at all?" If the symbol is absent or # CONFIG_FOO is not set, you need to rebuild.
git clone --depth=1 -b kan-stable-7.3 https://github.com/kan-linux/kernel
cd kernel
make O=/tmp/kbuild defconfig # or copy your running config (see below)
To start from your current configuration instead of defconfig:
zcat /proc/config.gz > /tmp/kbuild/.config
make O=/tmp/kbuild olddefconfig
4. Enable the driver
Find the driver for your hardware. Typical ways to locate it:
# search by PCI ID (kernel drivers declare their IDs in *pci*.c tables)
grep -r "0x51ca" drivers/sound/ -l
# search by chip name
grep -ri "8852be" drivers/net/wireless/
Then set the corresponding Kconfig symbol (e.g. CONFIG_RTW89_8852BE=m).
Pitfalls — read this before editing
Kernel configuration silently drops anything it cannot accept. The three most
common traps:
Symbol name must exist in your kernel tree. Names change between kernel
versions. Verify before writing:
(menuconfig FOO is also valid — check both forms.)
Parent gates must be opened first. Many drivers live behind a menu-level
switch. Example: all Intel sound machine drivers are inside if SND_SOC_INTEL_MACH; enabling the machine driver without CONFIG_SND_SOC_INTEL_MACH=y does nothing. When you enable a symbol, read
its enclosing if ... / depends on ... lines in the Kconfig file and
enable those too.
bool symbols accept only y or n — never m. Writing CONFIG_FOO=m for a bool option is invalid and gets reset to n.
Check the type:
grep -rn -A1 "^config FOO$" --include="Kconfig*".# look for 'bool' or 'tristate'
Verify the symbol actually landed
After editing .config, run olddefconfig and then confirm:
make O=/tmp/kbuild olddefconfig
grep CONFIG_FOO /tmp/kbuild/.config
If the symbol is missing or is not set, one of the pitfalls above hit you —
go back and check the name, the parent gates, and the type. Never assume a
config line took effect.
5. Build
make O=/tmp/kbuild -j$(nproc)
make O=/tmp/kbuild modules_install
This produces arch/x86/boot/bzImage (the kernel) and installs modules under /lib/modules/<version>/.
The previous kernel entry stays in the GRUB menu — if the new kernel fails to
boot, select it as a fallback.
7. Verify after reboot
uname -r # new version is running
zcat /proc/config.gz | grep FOO # the driver is enabled
dmesg | grep -i <driver># probe succeeded
Example of a healthy WiFi bring-up: the driver appears in lsmod, ip link
shows a wlan* interface, and dmesg contains no firmware or probe errors.
8. Firmware
Many drivers need firmware blobs in /lib/firmware/ (provided by the linux-firmware package). Symptoms of missing firmware in dmesg:
direct firmware load for ... failed
Copy the missing file from linux-firmware
into /lib/firmware/. Firmware can be compressed (.zst/.xz) — the kernel
accepts that when CONFIG_FW_LOADER_COMPRESS is enabled (it is, on kan-linux).
9. Worked example: enabling a Realtek WiFi card on a new laptop
lspci -nn | grep -i network
# 2b:00.0 Network controller [0280]: Realtek ... RTL8852BE [10ec:b852]
zcat /proc/config.gz | grep RTW89
# CONFIG_RTW89 is not set <- the family menu is off# in the kernel source:
grep -rn "b852\|8852BE" drivers/net/wireless/realtek/rtw89/ | head
# -> CONFIG_RTW89_8852BE
grep -rn -A1 "^menuconfig RTW89$" drivers/net/wireless/realtek/rtw89/Kconfig
# -> menuconfig RTW89 (parent gate!)
grep -rn -A1 "^config RTW89_8852BE$" drivers/net/wireless/realtek/rtw89/Kconfig
# -> tristate (=m is OK)# set both in .config:# CONFIG_RTW89=m# CONFIG_RTW89_8852BE=m
make O=/tmp/kbuild olddefconfig
grep RTW89 /tmp/kbuild/.config # both lines present -> good
make O=/tmp/kbuild -j$(nproc)&& make O=/tmp/kbuild modules_install
# install bzImage, grub-mkconfig, reboot
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
This doc describes how to build a customized kernel to adapt to your PC or laptop’s hardware on installed Kan-Linux.
kan-linux aims to support common consumer PC and laptop hardware out of the box. When a device on your machine is not recognized (no WiFi interface, no sound card, unknown PCI device in
lspci), you can usually fix it yourself by enabling the right driver and rebuilding the kernel. This guide walks through the full process.It is written for both humans and AI agents. Every step is deterministic: the inputs are your hardware, the running kernel config, and the kernel source tree.
1. Identify the hardware
The
vendor:deviceID fromlspci -nn(e.g.[8086:51ca]) is the key. You willuse it later to confirm which kernel driver claims the device.
2. Check the running kernel configuration
kan-linux ships the running kernel's configuration at
/proc/config.gz:This is the ground truth of what is actually built into your kernel. Use it to
answer: "is the driver I need enabled at all?" If the symbol is absent or
# CONFIG_FOO is not set, you need to rebuild.3. Get the kernel source
Use the source from kan-linux's kernel.
To start from your current configuration instead of
defconfig:zcat /proc/config.gz > /tmp/kbuild/.config make O=/tmp/kbuild olddefconfig4. Enable the driver
Find the driver for your hardware. Typical ways to locate it:
Then set the corresponding Kconfig symbol (e.g.
CONFIG_RTW89_8852BE=m).Pitfalls — read this before editing
Kernel configuration silently drops anything it cannot accept. The three most
common traps:
Symbol name must exist in your kernel tree. Names change between kernel
versions. Verify before writing:
(
menuconfig FOOis also valid — check both forms.)Parent gates must be opened first. Many drivers live behind a menu-level
switch. Example: all Intel sound machine drivers are inside
if SND_SOC_INTEL_MACH; enabling the machine driver withoutCONFIG_SND_SOC_INTEL_MACH=ydoes nothing. When you enable a symbol, readits enclosing
if .../depends on ...lines in the Kconfig file andenable those too.
boolsymbols accept onlyyorn— neverm. WritingCONFIG_FOO=mfor abooloption is invalid and gets reset ton.Check the type:
Verify the symbol actually landed
After editing
.config, runolddefconfigand then confirm:If the symbol is missing or
is not set, one of the pitfalls above hit you —go back and check the name, the parent gates, and the type. Never assume a
config line took effect.
5. Build
make O=/tmp/kbuild -j$(nproc) make O=/tmp/kbuild modules_installThis produces
arch/x86/boot/bzImage(the kernel) and installs modules under/lib/modules/<version>/.6. Install and boot
Copy the kernel and support files to
/boot:Update the bootloader (GRUB on kan-linux):
The previous kernel entry stays in the GRUB menu — if the new kernel fails to
boot, select it as a fallback.
7. Verify after reboot
Example of a healthy WiFi bring-up: the driver appears in
lsmod,ip linkshows a
wlan*interface, anddmesgcontains no firmware or probe errors.8. Firmware
Many drivers need firmware blobs in
/lib/firmware/(provided by thelinux-firmwarepackage). Symptoms of missing firmware indmesg:Copy the missing file from linux-firmware
into
/lib/firmware/. Firmware can be compressed (.zst/.xz) — the kernelaccepts that when
CONFIG_FW_LOADER_COMPRESSis enabled (it is, on kan-linux).9. Worked example: enabling a Realtek WiFi card on a new laptop
All reactions