Packetwatch.net

Smartmontools in FreeNAS



Last modified: Jan. 30, 2010

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


1 - Summary

This guide will show how to configure smartmontools in FreeNAS. Smartmontools
can run tests to monitor the SMART of hard disks. This has been tested in
FreeNAS 0.69.2.4700.


2 - Dependencies

Make sure that email has been configured using msmtp. We will use is to send
email notifications. Also, make sure that the SSH service has been enabled and
that sudo has been installed.

SSH into FreeNAS. It's helpful to know what type of hard disks the computer
has. You can find this out by typing the following.
> sysctl kern.disks
kern.disks: da0 ad5

In this case there are two hard drives. Get more information about the hard
disks by typing the following.
> dmesg | grep -e "^\da0" -e "^\ad5" | uniq
ad5: 76319MB <Seagate ST380815AS 4.AAB> at ata2-slave SATA150
da0 at twa0 bus 0 target 0 lun 0
da0: <AMCC 9500S-4LP  DISK 2.08> Fixed Direct Access SCSI-3 device 
da0: 100.000MB/s transfers
da0: 1907328MB (3906207744 512 byte sectors: 255H 63S/T 243150C)

The da0 disk is on a 3ware 9500S-4LP 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.60.04.005
twa0: <3ware 9000 series Storage Controller> port 0xe800-0xe8ff mem \
0xfebffc00-0xfebffcff,0xfd800000-0xfdffffff irq 19 at device 0.0 on pci1

Install the wget package.
> su - root
Password:
# pkg_add -r wget
# 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-4LP    4         3        1       0       1       1      OK       

//server> info c0

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

Port   Status           Unit   Size        Blocks        Serial
---------------------------------------------------------------
p0     OK               u0     931.51 GB   1953525168    6VP05LJS            
p1     OK               u0     931.51 GB   1953525168    6VP04P7W            
p2     OK               u0     931.51 GB   1953525168    6VP06D7L            
p3     NOT-PRESENT      -      -           -             -

Name  OnlineState  BBUReady  Status    Volt     Temp     Hours  LastCapTest
---------------------------------------------------------------------------
bbu   On           Yes       OK        OK       OK       255    13-Dec-2009  

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

//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.
> su - root
Password:
# pkg_add -r 3dm
# logout

Log into the website interface and go to the System menu, then Advanced and
click on rc.conf. Click on the plus symbol to add an option. Type in the
following.
  Name: twdm2_enable
  Value: YES
After typing in the information, click on Add then Apply changes.

Go back to the SSH session and typing 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 2858.


3 - Smartmontools configuration

Log into the website interface and go to the Disks menu and select Management.
For each hard disk, click on Edit disk on the right-hand of the screen. Next to
the line that says "S.M.A.R.T.", check the box that says "Activate S.M.A.R.T.
monitoring for this device." Click on Save. After that click on Apply changes.

Go to the Disks menu and select Management. Click on S.M.A.R.T. Check the
Enable box. Type in an email address in the field named "To email." Check the
Activate box and click on Save and Restart.

Go to the Advanced menu and select Command. Type in the following command and
click on Execute to make a backup of the newly created configuration file.
  Command: cp /var/etc/smartd.conf /var/etc/smartd.conf.example
Go to the Advanced menu and select File Editor. Type in the following file path
and click on Load.
  File path: /var/etc/smartd.conf
You can now create your own configuration file. Here is a simple example using
the included script. This will disable Autosave and will schedule a short
self-test between 8-9 PM every night and send warning emails 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. After typing in the information click on Save.
  /dev/ad5 -d ata -S off -s S/../.././20 -m notifications@test.com -a
  /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
Go to the Advanced menu and select Command. Type in the following command and
click on Execute to make a backup of the newly created configuration file.
   Command: cp /etc/rc.d/smartd /mnt/data/backups/originals/smartd
Go the Advanced menu and select File Editor. Type in the following file path
and click on Load.
  File path: /etc/rc.d/smartd
Modify the following near the end of the file to include the following. This
will need to be added since the smartd.conf file gets recreated everytime the
computer boots up. After typing in the information click on Save.
  #echo "${_devicespecialfile} ${_param}" >> ${smartd_conf}
  /bin/cat /dev/null > ${smartd_conf}
  echo "/dev/ad5 -d ata -S off -s S/../.././20 -m notifications@test.com -a" \
  >> ${smartd_conf}
  echo "/dev/twa0 -d 3ware,0 -S off -s S/../.././20 -m notifications@test.com -a" \
  >> ${smartd_conf}
  echo "/dev/twa0 -d 3ware,1 -S off -s S/../.././20 -m notifications@test.com -a" \
  >> ${smartd_conf}
  echo "/dev/twa0 -d 3ware,2 -S off -s S/../.././20 -m notifications@test.com -a" \
  >> ${smartd_conf}
SSH into FreeNAS and restart the smartmontools service.
> sudo /etc/rc.d/smartd restart
Password:
Stopping smartd.
Starting smartd.
> sudo /etc/rc.d/smartd status
Password:
smartd is running as pid 3529.


4 - 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-freebsd6.4] 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-freebsd6.4] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Device Model:     ST31000528AS
Serial Number:    6VP05LJS
Firmware Version: CC34
User Capacity:    1,000,204,886,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:    Thu Jan 28 23:48:48 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-freebsd6.4] 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-freebsd6.4] 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 Thu Jan 28 23:50:13 2010

Use smartctl -X to abort test.

This command lists the log of the selftest results.
> sudo smartctl -d 3ware,0 /dev/twa0 -l selftest
Password:
smartctl version 5.38 [i386-portbld-freebsd6.4] 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%      5025         -


5 - Service check

Reboot your computer. SSH back in to check to see that the smartmontools
service is running. That's it, now you have smartmontools running in FreeNAS.
> sudo shutdown -r now
Password:
> sudo /usr/local/etc/rc.d/3dm2 status
Password:
twdm2 is running as pid 1428.
> sudo /etc/rc.d/smartd status
Password:
smartd is running as pid 1563.


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