Side reading

Some failures produce warning counters; others are sudden. SMART is an early signal, not a guarantee.

Reading the drive #

smartctl and its scheduling daemon smartd come from the smartmontools package. nvme smart-log comes from nvme-cli:

$ sudo apt install smartmontools nvme-cli
$ sudo smartctl -a /dev/sda
$ sudo smartctl -H /dev/sda

-H gives the drive's own overall verdict, which is worth knowing and not worth trusting: drives pass their self-assessment right up until they do not.

For NVMe:

$ sudo smartctl -a /dev/nvme0
$ sudo nvme smart-log /dev/nvme0

The attributes that matter #

SMART names and raw values are vendor-specific. Read the drive manufacturer's documentation where available, and consider both a bad absolute value and change over time.

For spinning disks:

  • Reallocated_Sector_Ct. Sectors replaced from a spare pool. A stable non-zero raw value is evidence to investigate; a growing value is a strong replacement signal.
  • Current_Pending_Sector. Sectors the drive cannot read and has not yet reallocated. These are unreadable data right now. Worse than reallocated.
  • Offline_Uncorrectable. Could not be read or corrected. Treat like pending.
  • Reported_Uncorrect. Errors the drive could not fix.

For SSDs and NVMe:

  • Percentage_Used or Wear_Leveling_Count. How much of the rated write endurance is consumed. Predictable and slow; plan around it rather than reacting.
  • Media_and_Data_Integrity_Errors. Should be zero. Any value is a reason to look closer.
  • Available_Spare. Falling towards its threshold means the drive is running out of replacement blocks.

Temperature matters less than people expect within normal ranges, and a lot at extremes.

Test it rather than waiting #

$ sudo smartctl -t short /dev/sda     # a couple of minutes
$ sudo smartctl -t long /dev/sda      # hours; reads the whole surface
$ sudo smartctl -l selftest /dev/sda  # the results

A long test reads every sector, which is how pending sectors get discovered rather than waiting for you to read that file.

Choose a schedule appropriate to the drive, workload and vendor guidance. Do not start a long test while recovery copying or heavy application work is running. smartd can schedule tests and notifications.

Which numbers to alert on #

Chapter 14's monitoring can watch these, but node_exporter has no SMART collector of its own. Two options: run smartctl_exporter alongside it, or use the community smartmon.sh script on a timer, writing into node_exporter's --collector.textfile.directory.

Alert on change, not on level:

  • Reallocated sectors increased since last check.
  • Pending sectors above zero.
  • Available spare below the drive's own threshold.
  • SSD percentage used crossing 80.

A stable historical reallocation and a rapidly increasing count are different signals. Treat a change alongside health, error-log and backup evidence rather than relying on one universal number.

What to do when one moves #

Check your backups first. Before touching anything, confirm the last backup succeeded and run the restore drill. A failing disk is exactly when you find out whether your backups worked, and doing that discovery before you stress the drive is the whole point.

Do not run a long test on a drive that is actively failing if you have not got a good copy. Reading the whole surface can be the thing that finishes it.

Replace rather than nurse. A drive costs less than the afternoon. If pending sectors are non-zero and rising, it is done.

Copy with a tool that keeps going. GNU ddrescue records progress in a map file, skips unreadable regions and can retry them later. Read its manual and recover to a different healthy device; source and destination order is a destructive distinction.

The quiet failure mode #

The dangerous case is not a disk that dies. It is a disk that returns wrong data occasionally without reporting an error.

Filesystem checksums detect this: ZFS and Btrfs verify checksummed blocks on read. Repair still requires a valid redundant copy or backup. ext4 does not checksum ordinary file data. Chapter 7 turns on PostgreSQL data checksums so the database can detect some damaged pages even though the underlying ext4 file data has no equivalent check.

If silent corruption is part of your threat model, choose a checksumming filesystem together with scrub scheduling, redundancy and tested backups. Detection alone cannot reconstruct a good block.

Settings

Your values

The book is written with placeholder names so it makes sense to everybody. Put your own in and every chapter, every command and every copy-paste prompt updates to match.

Nothing here is sent anywhere. It is saved in this browser, so it comes back next time. A different browser or a private window gets the placeholders again.

Live preview

$ ssh admin@192.168.1.20
$ sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp
$ sudo hostnamectl set-hostname homeserver
$ sudo timedatectl set-timezone Europe/Paris

Real commands from chapters 2, 3 and 4. They change as you type.

The account you log in as. Not root, and not necessarily the same name you use on your laptop.

Introduced in Chapter 2, Meet your server

The book's placeholder is admin

What the machine calls itself. You choose it, and it shows up in your shell prompt and your logs.

Introduced in Chapter 3, A safe front door

The book's placeholder is homeserver

The IP address your server has on your home network, from ip -brief addr.

Introduced in Chapter 2, Meet your server

The book's placeholder is 192.168.1.20

The address range and prefix shown by ip route or ip -brief addr, written in CIDR form. Copy the real prefix; do not guess /24.

Introduced in Chapter 2, Meet your server

The book's placeholder is 192.168.1.0/24

The address traffic goes to on its way out of your house, from ip route.

Introduced in Chapter 2, Meet your server

The book's placeholder is 192.168.1.1

In Region/City form, or Etc/UTC if you would rather read logs in UTC.

Introduced in Chapter 3, A safe front door

The book's placeholder is Europe/Paris

A registered name you control. Chapter 8 uses it for the LAN route; chapter 12 uses a separate private Tailscale name remotely.

Introduced in Chapter 8, One door, many rooms

The book's placeholder is example.com

The email identity allowed to administer the tagged server in your Tailscale policy.

Introduced in Chapter 10, Your own private network

The book's placeholder is you@example.com

The mailbox that should receive actionable home-server alerts.

Introduced in Chapter 14, Knowing it is alive

The book's placeholder is alerts@example.com

Once you save, the prose and the commands read with your names, the copy buttons copy your values, and the copy-paste prompts describe your machine accurately. That last one matters: an assistant told your network is 192.168.1.0/24 when it is not will send you chasing the wrong thing.

Anything you leave empty keeps the book's placeholder.