Packetwatch.net

Smartmontools in FreeBSD



Last modified: Mar. 13, 2010

Contents
1 - Summary
2 - Dependencies
3 - Smartmontools installation
4 - Service configuration
5 - Smartctl examples
6 - Service check


1 - Summary

This guide will show you how to install smartmontools in FreeBSD. Smartmontools
can run tests to monitor the SMART of hard disks. This has been tested in
FreeBSD 7.0, 7.1, 7.2 and 8.0 using ATA and SATA hard drives.


2 - Dependencies

Install the msmtp packge. Msmtp is an SMTP client used to send email. We will
use it to send email notifications.
# sudo pkg_add -r msmtp
Password:

It's helpful to know what type of hard disk the computer has. You can find this
out by typing the following.
# sysctl kern.disks
kern.disks: da0

In this case there is a single hard disk which is da0. Get more information
about the hard disk by typing the following.
# dmesg | grep "^\da0" | uniq
da0 at twa0 bus 0 target 0 lun 0
da0: <AMCC 9500S-8    DISK 2.06> Fixed Direct Access SCSI-3 device 
da0: 100.000MB/s transfers
da0: 476816MB (976519168 512 byte sectors: 255H 63S/T 60785C)

The da0 disk is on a 3ware 9500S-8 controller card which is a SATA RAID card
meaning there are multiple hard disks connected to it in a RAID configuration.
# dmesg | grep -i 3ware | uniq
3ware device driver for 9000 series storage controllers, version: 3.70.05.001
twa0: <3ware 9000 series Storage Controller> port 0xe800-0xe8ff mem \
0xfebffc00-0xfebffcff,0xfd800000-0xfdffffff irq 16 at device 0.0 on pci1

Install the wget package.
# sudo pkg_add -r wget
Password:
# logout

The tw_cli software from 3ware has to be installed in order to get information
about the hard disks. This can be downloaded at http://www.3ware.com/.
# cd ~
# wget http://www.3ware.com/download/Escalade$model-Series/$ver/tw_cli-freebsd-$arch-$ver.tgz
# tar -zxvf tw_cli-freebsd-*.tgz
# ls -1
tw_cli
tw_cli-freebsd-*.tgz
tw_cli.8.html
tw_cli.8.nroff
# sudo cp tw_cli /sbin/
Password:
# sudo chmod +x /sbin/tw_cli 
Password:
# rm -f tw_cli*

Get more information about the hard disks attached to the 3ware controller by
typing the following. Since the hard disks are identical we will get the model
number of just one of them.
# sudo tw_cli
Password:
//server> info

Ctl   Model        (V)Ports  Drives   Units   NotOpt  RRate   VRate  BBU
------------------------------------------------------------------------
c0    9500S-8      8         3        1       0       1       1      -        

//server> info c0

Unit  UnitType  Status         %RCmpl  %V/I/M  Stripe  Size(GB)  Cache  AVrfy
------------------------------------------------------------------------------
u0    RAID-5    OK             -       -       64K     465.641   ON     OFF    

Port   Status           Unit   Size        Blocks        Serial
---------------------------------------------------------------
p0     OK               u0     232.88 GB   488397168     6VMBJCEG            
p1     OK               u0     232.88 GB   488397168     6VMBHY08            
p2     OK               u0     232.88 GB   488397168     5VM7ADL0            
p3     NOT-PRESENT      -      -           -             -
p4     NOT-PRESENT      -      -           -             -
p5     NOT-PRESENT      -      -           -             -
p6     NOT-PRESENT      -      -           -             -
p7     NOT-PRESENT      -      -           -             -

//server> info c0 p0 model
/c0/p0 Model = ST3250318AS

//server> quit

Now, with the model of the hard drives find out if they are ATA, SCSI or SAT.

Since some hard disks are attached to a 3ware SATA RAID controller, there is
also software from 3ware to view information via a website interface. Install
the 3dm package.
# sudo pkg_add -r 3dm
Password:

Edit /etc/rc.conf.local so that the 3dm service will start when the system
starts up. Somewhere in the file add the following.
  twdm2_enable="YES"
# sudo vi /etc/rc.conf.local 
Password:

Type the following to find and then start the 3dm service.
# pkg_info -L 3dm-* | grep rc.d
/usr/local/etc/rc.d/3dm2
# sudo /usr/local/etc/rc.d/3dm2 start
Password:
Starting twdm2.
# sudo /usr/local/etc/rc.d/3dm2 status
Password:
twdm2 is running as pid 1163.


3 - Smartmontools installation

Install the smartmontools package.
# sudo pkg_add -r smartmontools
Password:


4 - Service configuration

Find where the smartmontools daemon was installed to.
# pkg_info -L smartmontools-* | grep sbin
/usr/local/sbin/smartctl
/usr/local/sbin/smartd

Edit /etc/rc.conf.local so that the smartmontools service will start when the
system starts up. Somewhere in the file add the following.
  smartd_enable="YES"
# sudo vi /etc/rc.conf.local
Password:

Find where the configuration file should be put.
# grep smartd.conf /usr/local/etc/rc.d/smartd 
: ${smartd_config="/usr/local/etc/smartd.conf"}
: ${smartd_flags="-c ${smartd_config}"}
required_files="${smartd_config}"
# strings /usr/local/sbin/smartd | grep smartd.conf
/usr/local/etc/smartd.conf
Device: %s, no SMART Self-Test log; remove -l selftest Directive from smartd.conf
Device: %s, no SMART Error log; remove -l error Directive from smartd.conf

You can create your own configuration file. Here is a simple example. This
will disable Autosave and will schedule a short self-test between 8-9 PM every
night and send warnings or errors to the email address provided. Scheduled
tests are run after the default scheduled device polling, which by default
is every thirty minutes after the smartd service is started.
  /dev/twa0 -d 3ware,0 -S off -s S/../.././20 -m notifications@test.com -a
  /dev/twa0 -d 3ware,1 -S off -s S/../.././20 -m notifications@test.com -a
  /dev/twa0 -d 3ware,2 -S off -s S/../.././20 -m notifications@test.com -a
# pkg_info -L smartmontools-* | grep smartd.conf
/usr/local/man/man5/smartd.conf.5.gz
/usr/local/etc/smartd.conf.sample
/usr/local/share/doc/smartmontools/smartd.conf
# sudo cp /usr/local/etc/smartd.conf.sample /usr/local/etc/smartd.conf
Password:
# sudo cp /usr/local/etc/smartd.conf /usr/local/etc/smartd.conf.example
Password:
# sudo chmod u+w /usr/local/etc/smartd.conf
Password:
# sudo vi /usr/local/etc/smartd.conf
Password:

Start the smartmontools service.
# sudo /usr/local/etc/rc.d/smartd start
Password:
Starting smartd.
# sudo /usr/local/etc/rc.d/smartd status
Password:
smartd is running as pid 1279.


5 - Smartctl examples

Here are some basic examples of things you can find with smartctl. This
command enables SMART on the hard disks.
# sudo smartctl -d 3ware,0 /dev/twa0 -s on
Password:
smartctl version 5.38 [i386-portbld-freebsd8.0] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.

This command prints the device model number, serial number, firmware version,
and ATA Standard version/revision information.
# sudo smartctl -d 3ware,0 /dev/twa0 -i
Password:
smartctl version 5.38 [i386-portbld-freebsd8.0] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Device Model:     ST3250318AS
Serial Number:    6VMBJCEG
Firmware Version: CC38
User Capacity:    250,059,350,016 bytes
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   8
ATA Standard is:  ATA-8-ACS revision 4
Local Time is:    Sun Mar  7 19:21:53 2010 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

This command prints the SMART health status.
# sudo smartctl -d 3ware,0 /dev/twa0 -H
Password:
smartctl version 5.38 [i386-portbld-freebsd8.0] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

This command runs a SMART short self test.
# sudo smartctl -d 3ware,0 /dev/twa0 -t short
Password:
smartctl version 5.38 [i386-portbld-freebsd8.0] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Short self-test routine immediately in off-line mode".
Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 1 minutes for test to complete.
Test will complete after Sun Mar  7 19:25:24 2010

Use smartctl -X to abort test.

This command lists the log of selftest results.
# sudo smartctl -d 3ware,0 /dev/twa0 -l selftest
Password:
smartctl version 5.38 [i386-portbld-freebsd8.0] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%        11         -


6 - Service check

Reboot your computer. Log in like normal and check to see that the
smartmontools service is running. That's it, now you have smartmontools
running in FreeBSD.
# sudo shutdown -r now
Password:
# sudo /usr/local/etc/rc.d/3dm2 status
Password:
twdm2 is running as pid 615.
# sudo /usr/local/etc/rc.d/smartd status
Password:
smartd is running as pid 632.


Last modified: Thu Jan 1 00:00:00 1970 UTC
Packetwatch Research 2002-2024.