Linux Kernel 5.11 をセルフビルドしたメモ

Linux Kernel 5.11 がリリースされました.

F2FSの圧縮周りもアップデートがあるよう 🏛️なので試してみたくなりました.ということでセルフビルドしたらこれまで出なかったエラーが出たのでメモしておきます.

Warning
Debian sid amd64の 5.10.0-3-amd64 環境でビルドしました.Linux 5.9はビルドしたことがあるけれど,Linux 5.10はビルドしたことのない環境です.

Linux 5.11 build時にエラー( BTF: .tmp_vmlinux.btf: pahole (pahole) is not available )

以下のようなエラーが発生しました.

$ make -j`nproc` bindeb-pkg
〜省略〜
BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
〜省略〜
$ grep CONFIG_DEBUG_INFO_BTF ./.config
CONFIG_DEBUG_INFO_BTF=y

CONFIG_DEBUG_INFO_BTF を無効にすることも可能ですが, dwarves パッケージでDWARF utilitiesを導入するとこで解決しました.

$ sudo apt install dwarves

その他,DKMSでのVirtualBox moduleのビルドも失敗しました.これはVirtualBoxの対応待ちかなと思います.

ということで,以下のような感じで大丈夫そうです.

Linux 5.11のビルド

必要なパッケージの導入
$ sudo apt install build-essential linux-source bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves
ソースの入手,確認と展開
$ wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.11.tar.xz \
https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.11.tar.sign (1)
$ unxz ./linux-5.11.tar.xz (2)
$ gpg --verify ./linux-5.11.tar.sign (3)
gpg: assuming signed data in './linux-5.11.tar'
gpg: Signature made Mon 15 Feb 2021 06:11:32 PM JST
gpg:                using RSA key 647F28654894E3BD457199BE38DBBDC86092693E
gpg: Good signature from "Greg Kroah-Hartman <gregkh@linuxfoundation.org>" [unknown]
gpg:                 aka "Greg Kroah-Hartman (Linux kernel stable release signing key) <greg@kroah.com>" [undefined]
gpg:                 aka "Greg Kroah-Hartman <gregkh@kernel.org>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 647F 2865 4894 E3BD 4571  99BE 38DB BDC8 6092 693E
$ tar tvf ./linux-5.11.tar | lv (4)
$ tar xf ./linux-5.11.tar (5)
$ cd linux-5.11
  1. sourceと署名を入手
  2. 解凍
  3. 署名確認(署名はこちら 🏛️で確認)
  4. アーカイブ確認
  5. アーカイブ展開
configファイルの用意とビルド
$ cp /boot/config-`uname -r` ./.config (1)
$ yes "" | make oldconfig (2)
$ tar xf ../linux_5.10.9-1.debian.tar.xz debian/certs/ (3)
$ time make -j`nproc` bindeb-pkg (4)
  :
dpkg-deb: building package 'linux-libc-dev' in '../linux-libc-dev_5.11.0-1_amd64.deb'.
dpkg-deb: building package 'linux-image-5.11.0' in '../linux-image-5.11.0_5.11.0-1_amd64.deb'.
dpkg-deb: building package 'linux-image-5.11.0-dbg' in '../linux-image-5.11.0-dbg_5.11.0-1_amd64.deb'.
 dpkg-genbuildinfo --build=binary
 dpkg-genchanges --build=binary >../linux-5.11.0_5.11.0-1_amd64.changes
dpkg-genchanges: info: binary-only upload (no source code included)
 dpkg-source --after-build .
dpkg-buildpackage: info: binary-only upload (no source included)
$ ls -1s ../linux*.deb (5)
  7932 ../linux-headers-5.11.0_5.11.0-1_amd64.deb
728724 ../linux-image-5.11.0-dbg_5.11.0-1_amd64.deb
 52136 ../linux-image-5.11.0_5.11.0-1_amd64.deb
  1124 ../linux-libc-dev_5.11.0-1_amd64.deb
$ sudo apt install ../linux-image-5.11.0_5.11.0-1_amd64.deb ../linux-libc-dev_5.11.0-1_amd64.deb ../linux-headers-5.11.0_5.11.0-1_amd64.deb (6)
  1. 現在のkernel configをコピーする
  2. 新しい設定を既定値で設定
  3. Debianのkernel sourceから証明書をコピー(若しくは CONFIG_SYSTEM_TRUSTED_KEYS="" する)
  4. cpu数を指定してビルド開始
  5. 出来上がったパッケージの確認
  6. 出来上がったパッケージを導入
Machine Owner Key(MOK)で署名する(セキュアブートを有効にしている場合にのみ必要な処理)
$ sudo sbsign --key ~/MOK.priv --cert ~/MOK.pem /boot/vmlinuz-5.11.0 --output vmlinuz-5.11.0 (1)
$ sudo mv ./vmlinuz-5.11.0 /boot/vmlinuz-5.11.0
$ find /lib/modules/5.11.0/updates/dkms/ -type f | xargs -n1 sudo ./scripts/sign-file sha256 ~/MOK.priv ~/MOK.der (2)
  1. kernelに署名
  2. DKMSで作成したmoduleに署名

このあたりの処理は自動化できると思うんだけど未確認.
MOKの作成や,セキュアブートについては以下のページが参考になる.

環境

$ dpkg-query -W build-essential linux-source bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves sbsign
tool
bc      1.07.1-2+b2
build-essential 12.9
cpio    2.13+dfsg-4
dwarves 1.20-1
flex    2.6.4-8
kmod    28-1
libelf-dev:amd64        0.183-1
libncurses5-dev:amd64   6.2+20201114-2
libssl-dev:amd64        1.1.1j-1
linux-source    5.10.13-1
sbsigntool      0.9.2-2
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -mr
5.10.0-3-amd64 x86_64
再起動後
$ uname -mr
5.11.0 x86_64

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)