LinuxCommandLibrary

smartctl

Monitor and control storage device health

TLDR

Display SMART health summary

$ sudo smartctl [[-H|--health]] [/dev/sdX]
copy

Display device information
$ sudo smartctl [[-i|--info]] [/dev/sdX]
copy

Start a short/long self-test in the background
$ sudo smartctl [[-t|--test]] [short|long] [/dev/sdX]
copy

Display the self-test log
$ sudo smartctl [[-l|--log]] selftest
copy

Display current/last self-test status and other SMART capabilities
$ sudo smartctl [[-c|--capabilities]] [/dev/sdX]
copy

Display exhaustive SMART data
$ sudo smartctl [[-a|--all]] [/dev/sdX]
copy

SYNOPSIS

smartctl [options] device

PARAMETERS

-a, --all
    Display all S.M.A.R.T. information for the device, including health status, capabilities, attributes, and logs.

-i, --info
    Show S.M.A.R.T. information, including model, serial number, firmware version, and S.M.A.R.T. support status.

-H, --health
    Report S.M.A.R.T. health status. Indicates whether the drive's health attributes have exceeded their thresholds.

-c, --capabilities
    Display S.M.A.R.T. capabilities, such as available self-test types and error logging capabilities.

-l, --log=TYPE
    Display S.M.A.R.T. logs, including error logs and self-test logs. Types can be 'error', 'selftest', 'ssd', etc.

-t, --test=TYPE
    Perform a S.M.A.R.T. self-test on the device. Common types include 'short', 'long', 'conveyance', 'offline', 'selective'.

-s, --smart=on|off
    Enable or disable S.M.A.R.T. functionality on the device.

-X, --abort
    Abort a currently running S.M.A.R.T. self-test.

-d, --device=TYPE
    Specify the device type (e.g., 'ata', 'scsi', 'sat', 'nvme', 'usbjm', 'auto'). Essential for USB enclosures or RAID controllers.

-r, --raw
    Display raw S.M.A.R.T. attribute values without additional formatting. Useful for scripting.

-q, --quiet
    Suppress most output messages, useful when only the exit status is desired.

DESCRIPTION

smartctl is a command-line utility from the smartmontools package, used to monitor and control the Self-Monitoring, Analysis and Reporting Technology (S.M.A.R.T.) system built into most modern ATA/SATA and SCSI/SAS hard drives and solid-state drives (SSDs). S.M.A.R.T. allows the drive to report various attributes, such as temperature, read error rate, spin-up time, and reallocated sector counts, which can indicate impending drive failure. smartctl enables users to retrieve these S.M.A.R.T. data, perform self-tests, enable/disable S.M.A.R.T. functionality, and monitor drive health.

It's a critical tool for preventative maintenance, helping to anticipate and prevent data loss by identifying failing drives before they catastrophically fail. It supports a wide range of drive types and controllers, making it a versatile diagnostic tool for system administrators and users concerned about storage reliability.

CAVEATS

smartctl relies on the drive's built-in S.M.A.R.T. capabilities and a compatible kernel driver. Not all drives or controllers fully support S.M.A.R.T., or they may implement it non-standardly.

Running self-tests, especially long tests, can take a significant amount of time (hours) and may temporarily impact drive performance.

Accessing device information and performing actions often requires root privileges.

Interpreting S.M.A.R.T. attributes requires some understanding; high raw values for certain attributes (e.g., reallocated sectors) typically indicate an issue, while for others (e.g., temperature), a high value might be normal.

DEVICE NAMING

Devices are typically specified as /dev/sdX for SATA/SAS/SCSI drives (e.g., /dev/sda, /dev/sdb), or /dev/nvmeXnY for NVMe drives (e.g., /dev/nvme0n1). When using smartctl with USB enclosures or RAID controllers, the -d option is crucial to specify the correct device type (e.g., -d sat, -d usbjm, -d megaraid).

INTERPRETING S.M.A.R.T. ATTRIBUTES

smartctl outputs a table of attributes, each with an ID, current value, worst value, threshold, type (pre-fail or old-age), updated status, and raw value. Attributes marked as 'Pre-fail' are critical and indicate an immediate problem if their 'Value' drops below 'Thresh'. 'Old-age' attributes indicate normal wear and tear but can still signal a problem if they accumulate rapidly or reach concerning raw values. Understanding these values is key to proactive drive maintenance.

EXIT STATUS

smartctl provides meaningful exit status codes that are useful for scripting and automation. For example, an exit status of 0 typically means no errors were found, while non-zero codes can indicate S.M.A.R.T. health failures, command errors, or a self-test in progress. This allows smartctl to be integrated into automated monitoring and alerting systems.

HISTORY

S.M.A.R.T. technology was collaboratively developed by major hard drive manufacturers in the mid-1990s to provide early warning of impending disk failures. The smartmontools project, which includes smartctl and smartd, was initiated to provide open-source tools for interacting with this technology on Linux and other Unix-like operating systems.

It has been continuously developed since its inception, adding support for new drive interfaces (SATA, SAS, NVMe), controllers, and specific vendor implementations of S.M.A.R.T., making it a robust and widely adopted utility for disk health monitoring.

SEE ALSO

smartd(8), hdparm(8), lsblk(8), fdisk(8), badblocks(8), nvme-cli(1)

Copied to clipboard