From Gentoo Wiki
Jump to:navigation Jump to:search


smartmontools is a utility to read and monitor the S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) information of ATA/SATA and SCSI/SAS drives.



S.M.A.R.T. support needs to be enabled in the BIOS or EFI firmware for correct operation.

USE flags

USE flags for sys-apps/smartmontools Tools to monitor storage systems to provide advanced warning of disk degradation

caps Build against sys-libs/libcap-ng to allow smartd to drop its privileges.
daemon Install the monitoring daemon (smartd) and associated scripts.
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
static !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
update-drivedb Install a script to update the drivedb file.


Install sys-apps/smartmontools:

root #emerge --ask sys-apps/smartmontools



root #smartctl -h
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.61-gentoo] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke,

Usage: smartctl [options] device

============================================ SHOW INFORMATION OPTIONS =====

  -h, --help, --usage
         Display this help and exit

  -V, --version, --copyright, --license
         Print license, copyright, and version information and exit

  -i, --info
         Show identity information for device

         Show words and bits from IDENTIFY DEVICE data                (ATA)

  -g NAME, --get=NAME
        Get device setting: all, aam, apm, dsn, lookahead, security,
        wcache, rcache, wcreorder, wcache-sct

  -a, --all
         Show all SMART information for device

  -x, --xall
         Show all information for device

         Scan for devices

         Scan for devices and try to open each device

================================== SMARTCTL RUN-TIME BEHAVIOR OPTIONS =====

  -j, --json[=cgiosuvy]
         Print output in JSON or YAML format

  -q TYPE, --quietmode=TYPE                                           (ATA)
         Set smartctl quiet mode to one of: errorsonly, silent, noserial

  -d TYPE, --device=TYPE
         Specify device type to one of:
         ata, scsi[+TYPE], nvme[,NSID], sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,p][,x][,N], usbprolific, usbsunplus, sntjmicron[,NSID], sntrealtek, intelliprop,N[+TYPE], jmb39x[-q],N[,sLBA][,force][+TYPE], jms56x,N[,sLBA][,force][+TYPE], marvell, areca,N/E, 3ware,N, hpt,L/M/N, megaraid,N, aacraid,H,L,ID, cciss,N, auto, test

  -T TYPE, --tolerance=TYPE                                           (ATA)
         Tolerance: normal, conservative, permissive, verypermissive

  -b TYPE, --badsum=TYPE                                              (ATA)
         Set action on bad checksum to one of: warn, exit, ignore

  -r TYPE, --report=TYPE
         Report transactions (see man page)

  -n MODE[,STATUS], --nocheck=MODE[,STATUS]                     (ATA, SCSI)
         No check if: never, sleep, standby, idle (see man page)

============================== DEVICE FEATURE ENABLE/DISABLE COMMANDS =====

  -s VALUE, --smart=VALUE
        Enable/disable SMART on device (on/off)

  -o VALUE, --offlineauto=VALUE                                       (ATA)
        Enable/disable automatic offline testing on device (on/off)

  -S VALUE, --saveauto=VALUE                                          (ATA)
        Enable/disable Attribute autosave on device (on/off)

  -s NAME[,VALUE], --set=NAME[,VALUE]
        Enable/disable/change device setting: aam,[N|off], apm,[N|off],
        dsn,[on|off], lookahead,[on|off], security-freeze,
        standby,[N|off|now], wcache,[on|off], rcache,[on|off],
        wcreorder,[on|off[,p]], wcache-sct,[ata|on|off[,p]]

======================================= READ AND DISPLAY DATA OPTIONS =====

  -H, --health
        Show device SMART health status

  -c, --capabilities                                            (ATA, NVMe)
        Show device SMART capabilities

  -A, --attributes
        Show device SMART vendor-specific Attributes and values

  -f FORMAT, --format=FORMAT                                          (ATA)
        Set output format for attributes: old, brief, hex[,id|val]

  -l TYPE, --log=TYPE
        Show device log. TYPE: error, selftest, selective, directory[,g|s],
        xerror[,N][,error], xselftest[,N][,selftest], background,
        sasphy[,reset], sataphy[,reset], scttemp[sts,hist],
        scttempint,N[,p], scterc[,N,M], devstat[,N], defects[,N], ssd,
        gplog,N[,RANGE], smartlog,N[,RANGE], nvmelog,N,SIZE

  -v N,OPTION , --vendorattribute=N,OPTION                            (ATA)
        Set display OPTION for vendor Attribute N (see man page)

  -F TYPE, --firmwarebug=TYPE                                         (ATA)
        Use firmware bug workaround:
        none, nologdir, samsung, samsung2, samsung3, xerrorlba, swapid

  -P TYPE, --presets=TYPE                                             (ATA)
        Drive-specific presets: use, ignore, show, showall

  -B [+]FILE, --drivedb=[+]FILE                                       (ATA)
        Read and replace [add] drive database from FILE
        [default is +/etc/smart_drivedb.h
         and then    /var/db/smartmontools/drivedb.h]

============================================ DEVICE SELF-TEST OPTIONS =====

  -t TEST, --test=TEST
        Run test. TEST: offline, short, long, conveyance, force, vendor,N,
                        select,M-N, pending,N, afterselect,[on|off]

  -C, --captive
        Do test in captive mode (along with -t)

  -X, --abort
        Abort any non-captive test on device

=================================================== SMARTCTL EXAMPLES =====

  smartctl --all /dev/sda                    (Prints all SMART information)

  smartctl --smart=on --offlineauto=on --saveauto=on /dev/sda
                                              (Enables SMART on first disk)

  smartctl --test=long /dev/sda          (Executes extended disk self-test)

  smartctl --attributes --log=selftest --quietmode=errorsonly /dev/sda
                                      (Prints Self-Test & Attribute errors)
  smartctl --all --device=3ware,2 /dev/sda
  smartctl --all --device=3ware,2 /dev/twe0
  smartctl --all --device=3ware,2 /dev/twa0
  smartctl --all --device=3ware,2 /dev/twl0
          (Prints all SMART info for 3rd ATA disk on 3ware RAID controller)
  smartctl --all --device=hpt,1/1/3 /dev/sda
          (Prints all SMART info for the SATA disk attached to the 3rd PMPort
           of the 1st channel on the 1st HighPoint RAID controller)
  smartctl --all --device=areca,3/1 /dev/sg2
          (Prints all SMART info for 3rd ATA disk of the 1st enclosure
           on Areca RAID controller)


smartctl is a utility that is used to control and monitor S.M.A.R.T. enabled drives.


Print information of a drive, including S.M.A.R.T. support:

root #smartctl -i /dev/sda


Enable S.M.A.R.T. on a drive:

root #smartctl -s on /dev/sda

Print health

Print the S.M.A.R.T. health status of a drive:

root #smartctl -H /dev/sda

If the result is PASSED, the drive is in good health. If the result is FAILED, drive failure is imminent and the data should be backed up.

Print capabilities

Print the S.M.A.R.T. capabilities of a drive, including supported tests and the time required to run them:

root #smartctl -c /dev/sda

Print vendor specific attributes

Print the vendor specific S.M.A.R.T attributes of a drive:

root #smartctl -A /dev/sda

Run tests

Run a S.M.A.R.T. test on a drive:

root #smartctl -t TEST /dev/sda

The possible values for TEST include:

  • offline: Run the S.M.A.R.T. Immediate Offline Test.
  • short: Run the S.M.A.R.T. Short Self Test.
  • long: Run the S.M.A.R.T. Extended Self Test.
  • conveyance: Run the S.M.A.R.T. Conveyance Self Test.

Print logs

Print a S.M.A.R.T. log of a drive:

root #smartctl -l LOG /dev/sda

The possible values for LOG include:

  • error: Print the S.M.A.R.T. error log. This log will contain all errors. If the result is No Errors Logged, the drive is in good health. If there are some old errors, the drive is most likely in good health. If there are many recent errors, drive failure may be imminent and the data should be backed up.
  • selftest: Print the S.M.A.R.T. self-test log. This log will contain the results for the short, long and conveyance tests.

To send out notifications using custom scripts, place those scripts at /etc/smartd_warning.d. To run all scripts - add "@ALL" to the -m directive in /etc/smartd.conf. If the -m directive also contains an email address in the form of

FILE /etc/smartd.conf

the notification will be sent using both email address and custom scripts. For more information, see -m and -M sections of man smartd.conf

S.M.A.R.T. daemon

smartd is a daemon that continuously monitors the S.M.A.R.T. information of drives. It can be configured via /etc/smartd.conf. See man smartd.conf for more information. smartd will log any errors to /var/log/messages.

In this example smartd monitors 4 drives and sends a test e-mail on startup. It also runs a scheduled test every week on Friday at 3:00 a.m.

FILE /etc/smartd.conf
/dev/disk/by-id/ata-ST3000DM001-000000_00000000 -m -M test -H -l error -l selftest -f -s L/../../5/03
/dev/disk/by-id/ata-ST3000DM001-111111_11111111 -m -M test -H -l error -l selftest -f -s L/../../5/03
/dev/disk/by-id/ata-WDC_WD20EARS-00MVWB0_WD-000000000000 -m -M test -H -l error -l selftest -f -s L/../../5/03
/dev/disk/by-id/ata-WDC_WD20EARS-00MVWB0_WD-111111111111 -m -M test -H -l error -l selftest -f -s L/../../5/03

OpenRC service

FILE /etc/conf.d/smartd
# Add a net dependency for the smartd service

To start smartd:

root #/etc/init.d/smartd start

To start smartd at boot:

root #rc-update add smartd default

To debug smartd and check for possible configuration errors:

root #smartd -d
To stop the debugging instance of smartd, use Ctrl+\

External resources