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.
Inventory
Section titled “Inventory”| Command | What it gives |
|---|---|
lsblk -o NAME,SIZE,MODEL,TRAN,ROTA,MOUNTPOINTS | Disk tree, transport (usb, nvme, sata), rotating or not |
findmnt /mnt/data | Source, type and actual options of a mount |
duf | Free space, readable |
ls -l /dev/disk/by-id/ | Stable identifiers (wwn-, ata-, usb-) |
SMART health
Section titled “SMART health”Overall verdict first, detail next :
sudo smartctl -H /dev/sda # PASSED ou FAILEDsudo smartctl -a /dev/sda # tous les attributssudo smartctl --scan # disques vus, avec leur type (-d)A self-test is triggered on demand and read back later :
sudo smartctl -t short /dev/sda # ~2 min, non bloquantsudo smartctl -l selftest /dev/sda # résultats des derniers testsIs the disk spinning?
Section titled “Is the disk spinning?”sudo smartctl -n standby -i /dev/sda| Response | State |
|---|---|
Power mode is: ACTIVE or IDLE | Platter spinning |
Device is in STANDBY mode, exit(2) | Motor stopped |
Device is in SLEEP mode, exit(2) | Motor stopped, one level lower |
Setting or forcing standby
Section titled “Setting or forcing standby”-
Read the current settings
Fenêtre de terminal sudo smartctl -n standby -g all /dev/sda -
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êtsudo smartctl -d sat -s standby,240 /dev/sda # 240 x 5 s = 20 min d'inactivité -
Or stop the disk right away
Fenêtre de terminal sudo smartctl -d sat -s standby,now /dev/sda
Measuring actual activity
Section titled “Measuring actual activity”grep " sda " /proc/diskstatsFields 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.
On-demand mounts
Section titled “On-demand mounts”An x-systemd.automount mount is carried by two units :
systemctl status mnt-data.automount # le déclencheursystemctl status mnt-data.mount # le montage lui-mêmefindmnt /mnt/data # les deux lignes, autofs puis le vrai FSbtrfs filesystems
Section titled “btrfs filesystems”sudo btrfs filesystem usage /mnt/data # occupation réelle, données et métadonnéessudo btrfs device stats /mnt/data # compteurs d'erreurs par périphériquesudo btrfs scrub start -B /mnt/data # vérification complète, bloquante