Kernel

Prereq:
FS.md
IX.md

Disclaimer:
This guide is not for the faint of heart! It assumes that you have an idea of what a statically linked kernel is and know how to build it for your hardware in some source-based distro.

Also you can use any suitable kernel for your hardware, with:


This guide implies ix package manager in your PATH:

ix# export PATH=/mnt/ix/home/ix/ix:${PATH}   # assumes we are in stal/IX installer, before reboot
ix# export PATH=/home/ix/ix:${PATH}          # assumes we are in stal/IX installer, after reboot
ix# export PATH=/your/local/checkout:${PATH} # assumes local ix checkout per user
ix# ix list

The guide intends to build a kernel that contains all the components necessary for operation.

First, you need to know the list of modules for your hardware support.

You can download some conventional distro with a working hardware auto-detection system to do this.
It needs to execute:

ubuntu# lspci -k
03:00.0 Class 0300: 1002:1638 amdgpu
02:00.0 Class 0108: 144d:a809 nvme
03:00.7 Class 1180: 1022:15e4 pcie_mp2_amd
03:00.5 Class 0480: 1022:15e2 snd_rn_pci_acp3x
01:00.0 Class 0280: 8086:2723 iwlwifi
03:00.3 Class 0c03: 1022:1639 xhci_hcd
03:00.1 Class 0403: 1002:1637 snd_hda_intel
00:08.1 Class 0604: 1022:1635 pcieport
00:02.4 Class 0604: 1022:1634 pcieport
03:00.6 Class 0403: 1022:15e3 snd_hda_intel
00:02.2 Class 0604: 1022:1634 pcieport
03:00.4 Class 0c03: 1022:1639 xhci_hcd
03:00.2 Class 1080: 1022:15df ccp
00:14.0 Class 0c05: 1022:790b piix4_smbus
00:08.2 Class 0604: 1022:1635 pcieport
...

The last column - a list of modules that we need. Write them down.

Next, we need to prepare a directory with kernel sources for which we are building a config. Let’s say we want to use kernel 6.0:

ix# mkdir kernel
ix# cd kernel

# get current linux kernel source
ix# cat $(dirname $(which ix))/pkgs/bin/kernel/kernels.json | grep https
...
        "url": "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.7.1.tar.xz",
...

ix# wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.7.1.tar.xz
ix# tar xf linux-6.7.1.tar.xz
ix# cd linux-6.7.1

Copy old kernel config to our tree:

ix# cp $(dirname $(which ix))/pkgs/bin/kernel/configs/cfg_6_6_0 ./.config

Run the kernel configurator:

ix run set/menuconfig -- make HOSTCC=cc menuconfig

You need to find all the modules from the list above in the configurator (it has a search!) and add them to the configuration.


Herewith:


Alternatively, you can combine previous commands into one:

...
ix# cd linux-6.7.1
ix# ix tool reconf $(dirname $(which ix))/pkgs/bin/kernel/configs/cfg_6_6_0

Mostly, to understand what needs to be included in the kernel config for a particular device operation, it helps to search the Internet with the module’s name and a link to Gentoo/Arch as they have the largest knowledge base on the subject:

After the kernel is configured, copy the modified config to the base:

ix# cp .config $(dirname $(which ix))/pkgs/bin/kernel/configs/cfg_6_6_0

After that, you can add the kernel to the system realm in the usual way:

ix# ix mut system bin/kernel/6/7
ix# ls /bin/kernel-*
/bin/kernel-6-7-1...

Remember that path, you will need it later, in GRUB cli or in grub.cfg.

Alternatively, you can use a separate realm for the bootstrap kernel:

ix# ix mut kernel bin/kernel/6/7
ix# ls /ix/realm/kernel/bin/kernel-*
/ix/realm/kernel/bin/kernel-6-7-1-slot0

Remember that path, you will need it later, in GRUB cli or in grub.cfg.