Pour vérifier l’état du disque en temps réel j’utilise l’outil smart
Environnement
PC sous Linux Debian 10 ( Buster)
Logiciels installés
apt list --installed | grep smart
gedit-plugin-smart-spaces/testing,unstable,now 3.30.1-2 amd64 [installé, automatique]
gsmartcontrol/testing,unstable,now 1.1.3-2 amd64 [installé]
libatasmart4/testing,unstable,now 0.19-5 amd64 [installé, automatique]
libsmartcols1/testing,now 2.32.1-0.1 amd64 [installé]
smart-notifier/stable,stable,testing,testing,unstable,unstable,now 0.28-5 all [installé]
smartmontools/testing,unstable,now 6.6-1 amd64 [installé]
Configuration
Dans /etc/smartd.conf la seule ligne dé-commentée
DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/smartd-runner
Explications
https://linux.die.net/man/5/smartd.conf
removable - the device or its media is removable. This indicates to smartd that it should continue (instead of exiting, which is the default behavior) if the device does not appear to be present when smartd is started
standby - check the device unless it is in SLEEP or STANDBY mode. In these modes most disks are not spinning, so if you want to prevent a laptop disk from spinning up each time that smartd polls, this is probably what you want.
-m ADD
Send a warning email to the email address
-M
exec PATH - run the executable PATH instead of the default mail command, when smartd needs to send email. PATH must point to an executable binary file or script.
Commandes utiles
Dans mon cas le disque est /dev/sda
Lister les infos sur le disque
smartctl -a /dev/sda
Lancer un test court
smartctl -t short /dev/sda
Lire les résultats des tests
smartctl -l selftest /dev/sda
Vérifier l’état du service
systemctl status smartd.service -l --no-pager
Exemple
systemctl status smartd.service -l --no-pager
● smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon
_ Loaded: loaded (/lib/systemd/system/smartd.service; enabled; vendor preset: enabled)_
_ Active: active (running) since Sun 2018-11-25 12:23:02 CET; 2h 12min ago_
_ Docs: man:smartd(8)_
_ man:smartd.conf(5)_
_ Main PID: 578 (smartd)_
_ Tasks: 1 (limit: 4297)_
_ Memory: 3.1M_
_ CGroup: /system.slice/smartd.service_
_ └─578 /usr/sbin/smartd -n_
nov. 25 12:23:04 debian smartd[578]: Device: /dev/sda [SAT], found in smartd database: Hitachi Travelstar 7K500
nov. 25 12:23:05 debian smartd[578]: Device: /dev/sda [SAT], is SMART capable. Adding to “monitor” list.
nov. 25 12:23:05 debian smartd[578]: Device: /dev/sda [SAT], state read from /var/lib/smartmontools/smartd.Hitachi_HTS725032A9A364-110305PCKC04BPJ0X3GK.ata.state
nov. 25 12:23:05 debian smartd[578]: Monitoring 1 ATA/SATA, 0 SCSI/SAS and 0 NVMe devices
nov. 25 12:23:05 debian smartd[578]: Device: /dev/sda [SAT], SMART Usage Attribute: 190 Airflow_Temperature_Cel changed from 57 to 79
nov. 25 12:23:05 debian smartd[578]: Device: /dev/sda [SAT], state written to /var/lib/smartmontools/smartd.Hitachi_HTS725032A9A364-110305PCKC04BPJ0X3GK.ata.state
nov. 25 12:53:06 debian smartd[578]: Device: /dev/sda [SAT], SMART Usage Attribute: 190 Airflow_Temperature_Cel changed from 79 to 64
nov. 25 13:23:05 debian smartd[578]: Device: /dev/sda [SAT], SMART Usage Attribute: 190 Airflow_Temperature_Cel changed from 64 to 60
nov. 25 13:53:05 debian smartd[578]: Device: /dev/sda [SAT], SMART Usage Attribute: 190 Airflow_Temperature_Cel changed from 60 to 58
nov. 25 14:23:05 debian smartd[578]: Device: /dev/sda [SAT], SMART Usage Attribute: 190 Airflow_Temperature_Cel changed from 58 to 57
Automatisation
Ajouter une tâche hebdomadaire /etc/cron.weekly/smartctl
avec le contenu suivant:
#! /bin/bash
#set -e
/usr/sbin/smartctl -t short /dev/sda
/bin/sleep 180
/usr/sbin/smartctl -l selftest /dev/sda