Wednesday, September 30, 2015

Compiling and Using Custom Arch Linux Kernel

In my previous post, I have the need to downgrade my Arch Linux kernel version in order to alleviate ACPI bug in Linux kernel 4.X. After a bit of searching through AUR, I stumbled upon a still maintained kernel 3.X, at least until 2017. This kernel is Linux kernel 3.18. Because it resides in AUR, you must compile this kernel version yourself and install it with pacman. In this post, I will explain the process of compiling and installing custom kernel 3.18 from AUR. These are the steps I carried out to do that:
  1. Clone the kernel git repository with: git clone to directory where you're going to build the kernel.
  2. Add Linus Torvalds and Greg KH keys to list of trusted keys in pacman "database" of trusted keys:
    $ sudo pacman-key -r  00411886
    $ sudo pacman-key -r  6092693E
  3. Import Linus Torvalds and Greg KH public key to your machine if you haven't done that already.
    $ gpg --recv-keys 79BE3E4300411886
    $ gpg --recv-keys 38DBBDC86092693E
    Be patient, as it could take a while searching and importing the keys.
  4. Now, you can proceed to build the kernel in the git-cloned directory in step 1. cd into the directory and makepkg:
    $ makepkg -s
    The -s flag is to make sure that all dependencies are downloaded while building the custom kernel package.
  5. Assuming the kernel package build is finished, you can proceed to install the kernel headers and the kernel itself:
    # pacman -U linux-lts318-headers-3.18.20-1-x86_64.pkg.tar.xz
    # pacman -U linux-lts318-3.18.20-1-x86_64.pkg.tar.xz
    You are advised to install kernel header first before installing the kernel as mentioned in
  6. Once the kernel is installed, the remaining step is to update your machine bootloader. If you are using systemd bootloader (a.k.a gummiboot), all you need to do is modify /boot/loader/entries directory to include entry for the new kernel. For example: Create a new arch-lts.conf file in /boot/loader/entries with the following contents:
    title  Arch Linux 3.18 LTS AUR
    linux  /vmlinuz-linux-lts318
    initrd  /initramfs-linux-lts318.img
    options  root=PARTUUID=[your_root_partition_UUID] rw
That's all you need to do to compile and install custom kernel from AUR. If you want to create your own custom kernel, you need to build your own Arch Linux package. The compilation and installation steps should be similar to what's explained above.

  • If you have dirmngr problem showing up in your shell, it's probably because you haven't run it yet. You should run it as root:
    # dirmngr < /dev/null
    See: Pacman-key#gpg:_keyserver_receive_failed:_No_dirmngr
  • See also GnuPG section in Arch Wiki for more details.
  • If you'd rather prevent future kernel upgrade when upgrading packages via pacman -Syu, you can add this line to /etc/pacman.conf:
    IgnorePkg   = linux
    The line will prevent pacman from upgrading the linux kernel (linux package).

Post a Comment

No comments: