ThinkPad T14 Gen4（Intel）へのKaliLinuxインストールメモ

# はじめに
先日購入したThinkpad T14 Gen4にKali Linux 2023.3をクリーンインストールしようとしたら，少しハマってしまったので，メモとして残しておきます．どなたかの役に立ったら幸いです．

# ハマったポイント
## そもそもインストールができない
- グラフィカルインストールで導入パッケージの選択画面まで行き，パッケージを選択してインストールしようとしても失敗する．
    - Baseパッケージだけでいったんインストールを完了させる
    - 通常起動すると単なるコンソール画面になるので以下を実行する．
        - kali-tools-* は好みのものをインストールすればよい．

```zsh
sudo apt update
sudo apt full-upgrade -y
sudo apt install -y kali-linux-default
sudo apt install -y kali-desktop-core
sudo apt install -y kali-desktop-xfce
sudo apt install -y kali-tools-*
reboot
```

## AX211のfirmwareロードに失敗する
- T14に搭載されているWireless LANはAX211．
- lspciの結果は以下のとおり（SSDはWD SN580に換装済）

```zsh
lspci
00:00.0 Host bridge: Intel Corporation Raptor Lake-P/U 2p+8e cores Host Bridge/DRAM Controller (rev 01)
00:02.0 VGA compatible controller: Intel Corporation Raptor Lake-P [Iris Xe Graphics] (rev 04)
00:04.0 Signal processing controller: Intel Corporation Raptor Lake Dynamic Platform and Thermal Framework Processor Participant (rev 01)
00:06.0 PCI bridge: Intel Corporation Raptor Lake PCIe 4.0 Graphics Port (rev 01)
00:07.0 PCI bridge: Intel Corporation Raptor Lake-P Thunderbolt 4 PCI Express Root Port #0 (rev 01)
00:07.2 PCI bridge: Intel Corporation Raptor Lake-P Thunderbolt 4 PCI Express Root Port #2 (rev 01)
00:0d.0 USB controller: Intel Corporation Raptor Lake-P Thunderbolt 4 USB Controller (rev 01)
00:0d.2 USB controller: Intel Corporation Raptor Lake-P Thunderbolt 4 NHI #0 (rev 01)
00:0d.3 USB controller: Intel Corporation Raptor Lake-P Thunderbolt 4 NHI #1 (rev 01)
00:14.0 USB controller: Intel Corporation Alder Lake PCH USB 3.2 xHCI Host Controller (rev 01)
00:14.2 RAM memory: Intel Corporation Alder Lake PCH Shared SRAM (rev 01)
00:14.3 Network controller: Intel Corporation Raptor Lake PCH CNVi WiFi (rev 01)
00:16.0 Communication controller: Intel Corporation Alder Lake PCH HECI Controller (rev 01)
00:1f.0 ISA bridge: Intel Corporation Raptor Lake LPC/eSPI Controller (rev 01)
00:1f.3 Audio device: Intel Corporation Raptor Lake-P/U/H cAVS (rev 01)
00:1f.4 SMBus: Intel Corporation Alder Lake PCH-P SMBus Host Controller (rev 01)
00:1f.5 Serial bus controller: Intel Corporation Alder Lake-P PCH SPI Controller (rev 01)
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (23) I219-V (rev 01)
02:00.0 Non-Volatile memory controller: Sandisk Corp WD Blue SN580 NVMe SSD (DRAM-less) (rev 01)
```

- 対策しておかないと，```firmware: failed to load iwlwifi-so-a0-gf-a0-72.ucode (-2)```見たいのがたくさん出力される．
    - 以下を実行し，firmwareをインストール．バージョンは適宜最新版を．

```zsh
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-20231111.tar.gz
tar xvfz linux-firmware-20231111.tar.gz
sudo cp ./linux-firmware-20231111/iwlwifi-so-a0-gf-* /lib/firmware
sudo chown -R root:root /lib/firmware/iwlwifi-so-a0-gf-*
sudo modprobe -r iwlwifi
sudo modprobe iwlwifi
reboot
```

- 対策後のdmsgは以下のとおり(base HW addressはマスク済)
    - ```firmware: failed to load iwl-debug-yoyo.bin (-2)```は放置OK．

```zsh
dmesg | grep iwlwifi                                                                            
[    4.343382] iwlwifi 0000:00:14.3: enabling device (0000 -> 0002)
[    4.356853] iwlwifi 0000:00:14.3: Detected crf-id 0x400410, cnv-id 0x80400 wfpm id 0x80000020
[    4.356953] iwlwifi 0000:00:14.3: PCI dev 51f1/0090, rev=0x370, rfid=0x2010d000
[    4.359804] iwlwifi 0000:00:14.3: firmware: direct-loading firmware iwlwifi-so-a0-gf-a0-83.ucode
[    4.370732] iwlwifi 0000:00:14.3: api flags index 2 larger than supported by driver
[    4.370760] iwlwifi 0000:00:14.3: TLV_FW_FSEQ_VERSION: FSEQ Version: 0.0.2.41
[    4.371750] iwlwifi 0000:00:14.3: firmware: failed to load iwl-debug-yoyo.bin (-2)
[    4.371765] iwlwifi 0000:00:14.3: firmware: failed to load iwl-debug-yoyo.bin (-2)
[    4.371768] iwlwifi 0000:00:14.3: loaded firmware version 83.e8f84e98.0 so-a0-gf-a0-83.ucode op_mode iwlmvm
[    4.589299] iwlwifi 0000:00:14.3: Detected Intel(R) Wi-Fi 6E AX211 160MHz, REV=0x370
[    4.600026] iwlwifi 0000:00:14.3: WRT: Invalid buffer destination
[    4.762426] iwlwifi 0000:00:14.3: WFPM_UMAC_PD_NOTIFICATION: 0x20
[    4.762473] iwlwifi 0000:00:14.3: WFPM_LMAC2_PD_NOTIFICATION: 0x1f
[    4.762480] iwlwifi 0000:00:14.3: WFPM_AUTH_KEY_0: 0x90
[    4.762489] iwlwifi 0000:00:14.3: CNVI_SCU_SEQ_DATA_DW9: 0x0
[    4.763001] iwlwifi 0000:00:14.3: firmware: direct-loading firmware iwlwifi-so-a0-gf-a0.pnvm
[    4.763181] iwlwifi 0000:00:14.3: loaded PNVM version 674867bd
[    4.764050] iwlwifi 0000:00:14.3: RFIm is deactivated, reason = 4
[    4.779447] iwlwifi 0000:00:14.3: Detected RF GF, rfid=0x2010d000
[    4.849300] iwlwifi 0000:00:14.3: base HW address: **:**:**:**:**:**
[    5.099387] iwlwifi 0000:00:14.3: WRT: Invalid buffer destination
[    5.256935] iwlwifi 0000:00:14.3: WFPM_UMAC_PD_NOTIFICATION: 0x20
[    5.256995] iwlwifi 0000:00:14.3: WFPM_LMAC2_PD_NOTIFICATION: 0x1f
[    5.257003] iwlwifi 0000:00:14.3: WFPM_AUTH_KEY_0: 0x90
[    5.257011] iwlwifi 0000:00:14.3: CNVI_SCU_SEQ_DATA_DW9: 0x0
[    5.258455] iwlwifi 0000:00:14.3: RFIm is deactivated, reason = 4
[    5.358269] iwlwifi 0000:00:14.3: Registered PHC clock: iwlwifi-PTP, with index: 1
[    5.437147] iwlwifi 0000:00:14.3: WRT: Invalid buffer destination
[    5.593412] iwlwifi 0000:00:14.3: WFPM_UMAC_PD_NOTIFICATION: 0x20
[    5.593466] iwlwifi 0000:00:14.3: WFPM_LMAC2_PD_NOTIFICATION: 0x1f
[    5.593473] iwlwifi 0000:00:14.3: WFPM_AUTH_KEY_0: 0x90
[    5.593481] iwlwifi 0000:00:14.3: CNVI_SCU_SEQ_DATA_DW9: 0x0
[    5.595581] iwlwifi 0000:00:14.3: RFIm is deactivated, reason = 4
```

## Bluetoothが使えない
- 素直にインストールすればOK．
```zsh
apt-get install bluetooth
systemctl enable bluetooth
systemctl start bluetooth
```

## NetworkManagerにWireless-LANが有効表示されない
- OSインストール時にWireless-LANを利用していたため．interfacesファイルに（今となっては）不要な設定が残っていたので，```The primary network interface```行から下を削除またはコメント化．
```properties
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug wlan0
#iface wlan0 inet dhcp
#       wpa-ssid XXXXXXXXXX
#       wpa-psk  XXXXXXXXXX
```

# おわりに
- ThinkPad T14 Gen4＋KaliLinuxの情報が意外と少ない．というかT14＋Linuxの情報が少ない．
- 素直な良いマシンだと思ってる（個人的に）