Fixing the issue where Linux can't read sensor data on MSI B550M series motherboards

Translated from Simplified Chinese by AI.Read the original

Around the end of June, I put together a small All-in-One machine with an MSI B550M PRO-VDH motherboard. After installing Proxmox VE (based on Debian), I found that the data lm-sensors could get was really too sparse—even the temperatures were incomplete.

I could only get this:

root@home:~# sensors
nvme-pci-0100
Adapter: PCI adapter
Composite:    +38.9°C  (low  = -273.1°C, high = +89.8°C)
                       (crit = +94.8°C)
Sensor 1:     +38.9°C  (low  = -273.1°C, high = +65261.8°C)
Sensor 2:     +36.9°C  (low  = -273.1°C, high = +65261.8°C)

k10temp-pci-00c3
Adapter: PCI adapter
Tctl:         +41.0°C
Tccd1:        +40.0°C

I checked Reddit and found someone had run into a similar issue: the Linux kernel doesn't have native support for the Nuvoton NCT6687-R controller chip used on MSI B550M series motherboards, so you need to load a third-party Kernel Module yourself: Fred78290/nct6687d

Also, because Secure Boot is enabled, kernel modules need to be signed before they can be loaded, so I had to configure MOK (Machine Owner Key) and DKMS (Dynamic Kernel Module Support) automatic module signing.

Generate and register MOK

According to the Secure Boot section of the Debian Wiki, to stay consistent with Ubuntu, the MOK should be placed in the /var/lib/shim-signed/mok/ directory, and then generated with openssl:

mkdir -p /var/lib/shim-signed/mok/

cd /var/lib/shim-signed/mok/

openssl req -nodes -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -days 36500 -subj "/CN=Kernel Signing MOK/"

openssl x509 -inform der -in MOK.der -out MOK.pem

After creating the MOK, register it with mokutil:

mokutil --import /var/lib/shim-signed/mok/MOK.der

Set a one-time password for registration as prompted, note it down, and reboot

reboot

Next, follow the on-screen prompts, choose to register the MOK, and enter the one-time password you set earlier to confirm registration.

After booting, you can check whether the MOK was registered successfully:

mokutil --test-key /var/lib/shim-signed/mok/MOK.der

DKMS configuration

My Proxmox VE didn't seem to have DKMS preinstalled, so I had to install it manually:

apt-get update
apt-get install dkms

Then edit /etc/dkms/framework.conf, find the commented-out mok_signing_key and mok_certificate, uncomment them, and change them to the MOK locations from earlier

# Location of the key and certificate files used for Secure boot. $kernelver
# can be used in path to represent the target kernel version.
# mok_signing_key can also be a "pkcs11:..." string for PKCS#11 engine, as
# long as the sign_file program supports it.
# (default: /var/lib/dkms):
mok_signing_key=/var/lib/shim-signed/mok/MOK.priv
mok_certificate=/var/lib/shim-signed/mok/MOK.der

Build and install the module

Clone the repository and build it. Below are the steps to build a deb package and install it. On Proxmox VE it may complain about missing packages, such as build-essential and kernel headers—basically, install whatever is missing (o゜▽゜)o☆

For other distributions, you can refer to the README.md of Fred78290/nct6687d

cd /tmp
git clone https://github.com/Fred78290/nct6687d
cd nct6687d
make deb
dpkg -i ../nct6687d-dkms_*.deb

After installation, edit the /etc/modules file and add nct6687:

root@home:~# cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

nct6687

Then reboot, or use modprobe nct6687d to load the module

Run sensors-detect again

sensors-detect

Then just keep answering y, and it's done. Now let's look at what sensors shows:

root@home:~# sensors
nct6687-isa-0a20
Adapter: ISA adapter
+12V:           12.12 V  (min = +12.12 V, max = +12.14 V)
+5V:             5.08 V  (min =  +5.07 V, max =  +5.08 V)
+3.3V:           3.34 V  (min =  +0.00 V, max =  +3.34 V)
CPU Soc:       998.00 mV (min =  +1.00 V, max =  +1.00 V)
CPU Vcore:       1.17 V  (min =  +0.24 V, max =  +1.17 V)
CPU 1P8:         1.83 V  (min =  +1.83 V, max =  +1.83 V)
CPU VDDP:        0.00 V  (min =  +0.00 V, max =  +0.00 V)
DRAM:            1.35 V  (min =  +1.35 V, max =  +1.36 V)
Chipset:       784.00 mV (min =  +0.78 V, max =  +0.89 V)
CPU SA:        694.00 mV (min =  +0.69 V, max =  +0.86 V)
Voltage #2:      1.52 V  (min =  +1.52 V, max =  +1.53 V)
AVCC3:           3.38 V  (min =  +3.38 V, max =  +3.38 V)
AVSB:            3.34 V  (min =  +0.00 V, max =  +3.34 V)
VBat:            1.83 V  (min =  +0.00 V, max =  +1.83 V)
CPU Fan:        920 RPM  (min =  758 RPM, max =  920 RPM)
Pump Fan:         0 RPM  (min =    0 RPM, max =    0 RPM)
System Fan #1: 2238 RPM  (min = 2097 RPM, max = 2238 RPM)
System Fan #2:    0 RPM  (min =    0 RPM, max =    0 RPM)
System Fan #3:    0 RPM  (min =    0 RPM, max =    0 RPM)
System Fan #4:    0 RPM  (min =    0 RPM, max =    0 RPM)
System Fan #5:    0 RPM  (min =    0 RPM, max =    0 RPM)
System Fan #6:    0 RPM  (min =    0 RPM, max =    0 RPM)
CPU:            +45.0°C  (low  = +38.0°C, high = +45.0°C)
System:         +42.5°C  (low  = +35.0°C, high = +42.5°C)
VRM MOS:        +40.5°C  (low  = +33.0°C, high = +40.5°C)
PCH:            +43.5°C  (low  = +34.0°C, high = +43.5°C)
CPU Socket:     +40.0°C  (low  = +33.0°C, high = +40.0°C)
PCIe x1:        +38.0°C  (low  = +32.0°C, high = +38.0°C)
M2_1:            +0.0°C  (low  =  +0.0°C, high =  +0.0°C)

nvme-pci-0100
Adapter: PCI adapter
Composite:    +38.9°C  (low  = -273.1°C, high = +89.8°C)
                       (crit = +94.8°C)
Sensor 1:     +38.9°C  (low  = -273.1°C, high = +65261.8°C)
Sensor 2:     +36.9°C  (low  = -273.1°C, high = +65261.8°C)

k10temp-pci-00c3
Adapter: PCI adapter
Tctl:         +45.4°C
Tccd1:        +42.5°C

Ta-da (≧∇≦)ノ

Supporting kernel upgrades

After running apt dist-upgrade on Proxmox VE to upgrade the kernel, I saw the following message:

dkms: autoinstall for kernel 6.8.8-4-pve was skipped since the kernel headers for this kernel do not seem to be installed.

This is because the headers for the new kernel weren't installed (I had previously installed headers for a specific version). Here, I uninstalled the previously installed version-specific headers and installed the proxmox-headers-6.8 metapackage, which always points to the latest version of the PVE 6.8 kernel, so that every time I run apt dist-upgrade, the headers update together with the kernel.

After reboot, just run dkms autoinstall.