CentOS7のカーネルを3系から5系に上げる

はじめに

メインPCのマザーボードは ROG STRIX Z390-I GAMING を使っている.

heavymoon.hateblo.jp

このマザーボードは結構機能が豊富で Bluetooth 5.0 が使えることを思い出したので,これを使えるようにするためカーネルを上げる.

解説

Intel Wireless-AC 9650 とドライバ

このマザーボードには Intel Wireless-AC 9650 が搭載されており, Wi-Fi (802.11ac) と Bluetooth 5.0 の両方の機能を持っている.

ark.intel.com

M.2 のモジュールを利用して後から機能を追加することも出来る.

Linux 用のドライバは存在しているものの 4.14 以降のカーネルをサポートしており, CentoOS7 標準の3系では正常にモジュールを利用出来ない.

$ cat /etc/centos-release
CentOS Linux release 7.7.1908 (Core)
$ uname -r
3.10.0-1062.12.1.el7.x86_64

インテルワイヤレスアダプター Linuxドライバ

対策

対策としては2つ.

  1. 自分でカーネルモジュールをビルドする
  2. カーネルのバージョンを上げる

カーネルモジュールのビルドは他のモジュールとの依存関係やカーネル更新のたびに再ビルドする手間もかかるため,ハードルは高め.

もしも自分でビルドしたい場合は Arch のドキュメントが参考になる.

wiki.archlinux.jp

カーネルを上げる場合は ELRepo の elrepo-kernel を利用するといい.

elrepo.org

kernel-lt と kernel-ml の2種類のカーネルが用意してあり, kernel-lt の lt は long term support を, kernel-ml の ml は mainline stable を表している.

確認時点のバージョンは以下の通り.

$ yum info --enablerepo elrepo-kernel kernel-ml kernel-lt
利用可能なパッケージ
名前                : kernel-lt
アーキテクチャー    : x86_64
バージョン          : 4.4.219
リリース            : 1.el7.elrepo
容量                : 39 M
リポジトリー        : elrepo-kernel
要約                : The Linux kernel. (The core of any Linux-based operating system.)
URL                 : https://www.kernel.org/
ライセンス          : GPLv2
説明                : This package provides the Linux kernel (vmlinuz), the core of any
                    : Linux-based operating system. The kernel handles the basic functions
                    : of the OS: memory allocation, process allocation, device I/O, etc.

名前                : kernel-ml
アーキテクチャー    : x86_64
バージョン          : 5.6.5
リリース            : 1.el7.elrepo
容量                : 49 M
リポジトリー        : elrepo-kernel
要約                : The Linux kernel. (The core of any Linux-based operating system.)
URL                 : https://www.kernel.org/
ライセンス          : GPLv2
説明                : This package provides the Linux kernel (vmlinuz), the core of any
                    : Linux-based operating system. The kernel handles the basic functions
                    : of the OS: memory allocation, process allocation, device I/O, etc.

カーネルバージョンアップ

ELRepo リポジトリ設定

$ sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
$ sudo yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

ここは ELRepo の手順通り.

カーネル関連パッケージインストール

$ yum search --enablerepo elrepo-kernel kernel-ml
$ sudo yum --enablerepo elrepo-kernel install kernel-ml
$ sudo yum --enablerepo elrepo-kernel swap    kernel-headers    kernel-ml-headers
$ sudo yum --enablerepo elrepo-kernel swap    kernel-tools-libs kernel-ml-tools-libs
$ sudo yum --enablerepo elrepo-kernel install kernel-ml-tools
$ sudo yum --enablerepo elrepo-kernel swap    kernel-devel      kernel-ml-devel

今回は ml の方を入れる.

カーネルを入れ替えようと考えるギークな人は kernel-headers などのカーネル関連パッケージも入ってるかもしれない. yum swapを使ってこれらのパッケージも ml 用に入れ替える.

ちなみに kernel-tools-libs をswap すると依存関係で kernel-tools もアンインストールされるため, kernel-ml-tools だけ単純に install となっている.

起動時のカーネル変更

$ sudo grub2-editenv list
saved_entry=CentOS Linux (3.10.0-1062.12.1.el7.x86_64) 7 (Core)

このままだと再起動後に kernel-ml でなく,3系のカーネルで起動するので変更する.

grub で指定出来るカーネルを確認する.
/etc/grub2.cfg の menuentry の行を参照すればいい.
awk で適当に抽出するのが通例らしい.(これくらいコマンド用意しといてほしい...)

$ sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (5.6.6-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-1062.12.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-1062.9.1.el7.x86_64) 7 (Core)
3 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
4 : CentOS Linux (0-rescue-8f2ef6bed54e47f2a4199ff24c66907e) 7 (Core)

もしも /etc/grub2.cfg が見当たらなければ次のコマンドで設定をファイル作る.

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg

kernel-ml の番号を指定して,起動時のカーネルを変更する.

$ sudo grub2-set-default 0

後は再起動すれば kernel-ml で起動してくれる.

再起動する前に

このまま再起動すると graphical.target で起動してくるので, グラボを挿している場合はこちらのドライバも更新しておかないと画面映らなくなるかも.

heavymoon.hateblo.jp

再起動前にドライバの更新準備(ドライバの用意とランレベルの変更)をしておくこと.

その他,思い残すことがなければ再起動する.

$ sudo reboot

カーネル確認

$ uname -r
5.6.6-1.el7.elrepo.x86_64

無事5系に上がった.

おわりに

これで Intel Wireless-AC 9650 を使う準備が出来た. Bluetooth の接続についてはまた今度.

Kibana の話はもう少しデータ溜まってから書く.たぶん.