Jump to content

Smartmontools: Difference between revisions

From NixOS Wiki
Unabomberlive (talk | contribs)
Marked this version for translation
Instruct on using persistent device ids for smartd
(3 intermediate revisions by 2 users not shown)
Line 9: Line 9:
</translate>
</translate>
<translate>
<translate>
== Locating devices ==
It is important to use persistent methods of identification for disks, as device nodes are arbitrary and subject to change. The following command will print a list of storage devices, as well as partitions contained on them. When configuring smartd, you should use entries that are '''not''' suffixed with "-partX", as they refer to whole disks. <syntaxhighlight lang="bash">
ls /dev/disk/by-id/
</syntaxhighlight>
== Example == <!--T:3-->
== Example == <!--T:3-->
</translate>
</translate>
<translate>
<!--T:4-->
{{Template:file:nixos|<nowiki>{
{{Template:file:nixos|<nowiki>{
   services.smartd = {
   services.smartd = {
Line 16: Line 24:
     devices = [
     devices = [
       {
       {
        <translate>
         device = "/dev/disk/by-id/ata-WDC-XXXXXX-XXXXXX"; # FIXME: Change this to your actual disk
         device = "/dev/sda"; # FIXME: Change this to your actual disk; use lsblk to find the appropriate value
</translate>
       }
       }
     ];
     ];
Line 24: Line 30:
}
}
</nowiki>}}
</nowiki>}}
</translate>


[[Category:Hardware]]
[[Category:Hardware]]
[[Category:Software]]
[[Category:Applications]]

Revision as of 22:29, 17 February 2025

smartmontools is a package which provides tools for monitoring drives which support the S.M.A.R.T. system for monitoring hard drive health. It includes the smartd and smartctl programs. smartd can be enabled on NixOS systems with the services.smartd module.

Locating devices

It is important to use persistent methods of identification for disks, as device nodes are arbitrary and subject to change. The following command will print a list of storage devices, as well as partitions contained on them. When configuring smartd, you should use entries that are not suffixed with "-partX", as they refer to whole disks.

ls /dev/disk/by-id/

Example

❄︎ /etc/nixos/configuration.nix
{
  services.smartd = {
    enable = true;
    devices = [
      {
        device = "/dev/disk/by-id/ata-WDC-XXXXXX-XXXXXX"; # FIXME: Change this to your actual disk
      }
    ];
  };
}