先日Debian sid amd64環境でapt upgradeしたときにhddtempのNEWSがあることに気づきました.
$ zcat /usr/share/doc/hddtemp/NEWS.Debian.gz
hddtemp (0.3-beta15-54) unstable; urgency=medium
hddtemp has been dead upstream for many years and is therefore in a minimal
maintenance mode. It will be shipped in the Debian Bullseye release, but
will not be present in the Debian Bookworm release.
Nowadays the 'drivetemp' kernel module is a better alternative. It uses the
Linux Hardware Monitoring kernel API (hwmon), so the temperature is returned
the same way and using the same tools as other sensors.
Loading this module is as easy as creating a file in the /etc/modules-load.d
directory:
echo drivetemp > /etc/modules-load.d/drivetemp.conf
-- Aurelien Jarno <aurel32@debian.org> Tue, 02 Feb 2021 20:27:44 +0100
hddtempは対応しているストレージの温度を取得できます.
$ sudo hddtemp /dev/sda
/dev/sda: Seagate BarraCuda SSD ZA0100MC0100 2 : 41°C
しかしこのNEWSによると hddtemp はもう上流でメンテナンスされていないのでDebianの次期バージョンの Bullseye には入るけどその次の Bookworm からは除かれる予定のようです.
そして drivetemp
というカーネルモジュールが代替になるとのこと.
てことで少し試してみました.
drivetempについてはkernelのドキュメントを確認します.
zcat /usr/share/doc/linux-doc-5.10/Documentation/hwmon/drivetemp.rst.gz | rst2html | w3m -T text/html
Kernel driver drivetemp
References
ANS T13/1699-D Information technology – AT Attachment 8 – ATA/ATAPI Command Set
(ATA8-ACS)
ANS Project T10/BSR INCITS 513 Information technology – SCSI Primary Commands –
4 (SPC-4)
ANS Project INCITS 557 Information technology – SCSI / ATA Translation – 5
(SAT-5)
Description
This driver supports reporting the temperature of disk and solid state drives
with temperature sensors.
If supported, it uses the ATA SCT Command Transport feature to read the current
drive temperature and, if available, temperature limits as well as historic
minimum and maximum temperatures. If SCT Command Transport is not supported,
the driver uses SMART attributes to read the drive temperature.
Usage Note
Reading the drive temperature may reset the spin down timer on some drives.
This has been observed with WD120EFAX drives, but may be seen with other drives
as well. The same behavior is observed if the ‘hdtemp’ or ‘smartd’ tools are
used to access the drive. With the WD120EFAX drive, reading the drive
temperature using the drivetemp driver is still possible after it
transitioned to standby mode, and reading the drive temperature in this mode
will not cause the drive to change its mode (meaning the drive will not spin
up). It is unknown if other drives experience similar behavior.
A known workaround for WD120EFAX drives is to read the drive temperature at
intervals larger than twice the spin-down time. Otherwise affected drives will
never spin down.
Sysfs entries
Only the temp1_input attribute is always available. Other attributes are
available only if reported by the drive. All temperatures are reported in
milli-degrees Celsius.
┌─────────────┬───────────────────────────────────────────────────────────────┐
│temp1_input │Current drive temperature │
├─────────────┼───────────────────────────────────────────────────────────────┤
│temp1_lcrit │Minimum temperature limit. Operating the device below this │
│ │temperature may cause physical damage to the device. │
├─────────────┼───────────────────────────────────────────────────────────────┤
│temp1_min │Minimum recommended continuous operating limit │
├─────────────┼───────────────────────────────────────────────────────────────┤
│temp1_max │Maximum recommended continuous operating temperature │
├─────────────┼───────────────────────────────────────────────────────────────┤
│temp1_crit │Maximum temperature limit. Operating the device above this │
│ │temperature may cause physical damage to the device. │
├─────────────┼───────────────────────────────────────────────────────────────┤
│temp1_lowest │Minimum temperature seen this power cycle │
├─────────────┼───────────────────────────────────────────────────────────────┤
│temp1_highest│Maximum temperature seen this power cycle │
└─────────────┴───────────────────────────────────────────────────────────────┘
drivetempを読み込むとSysfs で temp1_input
として出てくるようです.
$ find /sys/ -name "temp1_input" > /tmp/before.list 2>/dev/null
$ cat /tmp/before.list
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon3/temp1_input
/sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input
/sys/devices/virtual/thermal/thermal_zone0/hwmon0/temp1_input
drivetemp
モジュールの読み込み$ sudo modprobe -v drivetemp
insmod /lib/modules/5.10.0-3-amd64/kernel/drivers/hwmon/drivetemp.ko
Note
|
永続化したい場合は$ echo drivetemp | sudo tee /etc/modules-load.d/drivetemp.conf |
$ find /sys/ -name "temp1_input" 2>/dev/null | diff -u /tmp/before.list -
--- /tmp/before.list 2021-02-05 01:45:58.691517588 +0900
+++ - 2021-02-05 01:46:00.178371154 +0900
@@ -1,3 +1,4 @@
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon3/temp1_input
/sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input
+/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/hwmon/hwmon6/temp1_input
/sys/devices/virtual/thermal/thermal_zone0/hwmon0/temp1_input
$ cat /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/hwmon/hwmon6/temp1_input
44000
$ sudo hddtemp /dev/sda
/dev/sda: Seagate BarraCuda SSD ZA0100MC0100 2 : 44°C
hddtemp
と同じ結果が取得できました.同じなので drivetemp
の値は摂氏のようですね :)
とりあえず温度は取得できましたがデバイスから温度を取得したりデーモンなどは使えないのでそのへんは少し考えないといけなさそうです.