Skip to content

Introspect and manage disks

Common commands for inventorying, monitoring and driving a host’s disks. smartctl is provided by the administrator profile, the other tools are part of the base system.

CommandWhat it gives
lsblk -o NAME,SIZE,MODEL,TRAN,ROTA,MOUNTPOINTSDisk tree, transport (usb, nvme, sata), rotating or not
findmnt /mnt/dataSource, type and actual options of a mount
dufFree space, readable
ls -l /dev/disk/by-id/Stable identifiers (wwn-, ata-, usb-)

Overall verdict first, detail next :

Fenêtre de terminal
sudo smartctl -H /dev/sda # PASSED ou FAILED
sudo smartctl -a /dev/sda # tous les attributs
sudo smartctl --scan # disques vus, avec leur type (-d)

A self-test is triggered on demand and read back later :

Fenêtre de terminal
sudo smartctl -t short /dev/sda # ~2 min, non bloquant
sudo smartctl -l selftest /dev/sda # résultats des derniers tests
Fenêtre de terminal
sudo smartctl -n standby -i /dev/sda
ResponseState
Power mode is: ACTIVE or IDLEPlatter spinning
Device is in STANDBY mode, exit(2)Motor stopped
Device is in SLEEP mode, exit(2)Motor stopped, one level lower
  1. Read the current settings

    Fenêtre de terminal
    sudo smartctl -n standby -g all /dev/sda
  2. Allow standby, then arm the internal timer

    Fenêtre de terminal
    sudo smartctl -d sat -s apm,127 /dev/sda # niveau APM >= 128 : jamais d'arrêt
    sudo smartctl -d sat -s standby,240 /dev/sda # 240 x 5 s = 20 min d'inactivité
  3. Or stop the disk right away

    Fenêtre de terminal
    sudo smartctl -d sat -s standby,now /dev/sda
Fenêtre de terminal
grep " sda " /proc/diskstats

Fields 4 and 8 : completed reads and writes. Comparing two readings taken apart gives the disk’s actual activity. SMART commands do not appear there, which makes it the right sensor for judging idleness.

For history rather than a snapshot, the metric node_disk_io_time_seconds_total is collected on every monitored host, see Supervision.

An x-systemd.automount mount is carried by two units :

Fenêtre de terminal
systemctl status mnt-data.automount # le déclencheur
systemctl status mnt-data.mount # le montage lui-même
findmnt /mnt/data # les deux lignes, autofs puis le vrai FS
Fenêtre de terminal
sudo btrfs filesystem usage /mnt/data # occupation réelle, données et métadonnées
sudo btrfs device stats /mnt/data # compteurs d'erreurs par périphérique
sudo btrfs scrub start -B /mnt/data # vérification complète, bloquante