It turned out that every laptop I owned happened to need custom kernel eventually. For instance, Acer C720 had a less popular light sensor, HP needed a specific version of WiFi driver etc. And this time, Xiaomi Mi Notebook Air, doesn’t work well with the kernels younger than 4.10, the touchpad becomes unbearable jerky. Luckily there is an AUR package with LTS kernel linux-lts49. Unfortunately, it can’t be built in tmpfs because of limited size. But it turns out that building minimal kernels is very easy in Arch linux indeed.

First, there is a service recording the names of kernel modules that were ever loaded in the system: modprobed-db. It also allows interactive usage.

Second, one line needs be put into PKGBUILD:

make LSMOD=$HOME/.config/modprobed.db localmodconfig

This will configure the kernel build to only include specific needed modules.

The result is impressing:

  • The build finishes within 15 minutes (much less than I sent writing text)
  • Fits into 2 GB /tmp with much to spare
  • The kernel is fully functional
  • Easy to keep it up to date