среда, 10 мая 2023 г.

How to build and install the kernel

 Sources:

  • https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel#apt-get
  • https://www.maketecheasier.com/build-custom-kernel-ubuntu/
  • https://stackoverflow.com/a/75622441


The algorithm:

  1. Make source directory (I have named it 'lab') and go there: `mkdir ~/lab; cd ~/lab` 
  2. Download linux sources of your distributes: `apt-get source linux-image-unsigned-$(uname -r)`
  3. Download linux sources from git repository: `git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git`
  4. Go to the Linus' source directory: `cd ~/lab/linux`
  5. Copy your distribution's config: `cp /boot/config-$(uname -r) .config`
  6. Apply the config: `make olddefconfig`
  7. Copy a directory of your distribution's source in order to sign your build: `cp -avr ~/lab/linux-hwe-5.15-5.15.0/debian ~/lab/linux/debian`
  8. Build the kernel: `make clean && make -j8`
  9. Build deb-package: `make deb-pkg LOCALVERSION=-custom`
  10. Install deb-packages: `sudo dpkg -i ~/lab/linux-*.deb`
  11. Reboot your system with a new kernel =)