Packetwatch.net

Smartmontools in Mythbuntu



Last modified: Jun. 3, 2012

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


1 - Summary

This guide will show how to install smartmontools in Mythbuntu. Smartmontools
can run tests to monitor the SMART of hard disks. This has been tested in
Mythbuntu 12.04.


2 - Dependencies

Install the apt-file package.
# sudo apt-get install apt-file
[sudo] password for user:

Install the msmtp package. Msmtp is an SMTP client used to send email. We will
use it to send email notifications.
# sudo apt-get install msmtp
[sudo] password for user: 

It's helpful to know what type of hard disks the computer has. You can find
this out by typing the following.
# sudo parted -l | grep Disk 
[sudo] password for user: 
Disk /dev/sda: 4000GB
Disk /dev/sdb: 2000GB

In this case there are two hard drives which are RAID arrays. Get more
information about the RAID arrays by typing the following.
# dmesg | grep -e '\[sda]\|\[sdb]' | uniq
[    4.086551] sd 6:0:0:0: [sda] Very big device. Trying to use READ CAPACITY(16).
[    4.086735] sd 6:0:0:0: [sda] 7812415488 512-byte logical blocks: (3.99 TB/3.63 TiB)
[    4.087699] sd 6:0:0:0: [sda] Write Protect is off
[    4.087702] sd 6:0:0:0: [sda] Mode Sense: 23 00 00 00
[    4.087897] sd 6:0:1:0: [sdb] 3906207744 512-byte logical blocks: (1.99 TB/1.81 TiB)
[    4.089475] sd 6:0:1:0: [sdb] Write Protect is off
[    4.089479] sd 6:0:1:0: [sdb] Mode Sense: 23 00 00 00
[    4.090414] sd 6:0:0:0: [sda] Write cache: enabled, read cache: disabled, doesn't support DPO or FUA
[    4.091741] sd 6:0:1:0: [sdb] Write cache: enabled, read cache: disabled, doesn't support DPO or FUA
[    4.091932] sd 6:0:0:0: [sda] Very big device. Trying to use READ CAPACITY(16).
[    4.120801] sd 6:0:1:0: [sdb] Attached SCSI disk
[    4.157155] sd 6:0:0:0: [sda] Very big device. Trying to use READ CAPACITY(16).
[    4.160640] sd 6:0:0:0: [sda] Attached SCSI disk
# dmesg | grep -i scsi | grep -e '6:0:0:0:\|6:0:1:0:'
[    4.065099] scsi 6:0:0:0: Direct-Access     AMCC     9500S-8    DISK  2.08 PQ: 0 ANSI: 3
[    4.067449] scsi 6:0:1:0: Direct-Access     AMCC     9500S-8    DISK  2.08 PQ: 0 ANSI: 3
[    4.086386] sd 6:0:0:0: Attached scsi generic sg1 type 0
[    4.086519] sd 6:0:1:0: Attached scsi generic sg2 type 0
[    4.120801] sd 6:0:1:0: [sdb] Attached SCSI disk
[    4.160640] sd 6:0:0:0: [sda] Attached SCSI disk

The sda and sdb disks are on a 3ware 9500S-8 controller card which is a SATA
RAID card meaning that there are multiple hard disks connected to it in a RAID
configuration.
# dmesg | grep -i 3ware | uniq
[    3.002563] 3ware 9000 Storage Controller device driver for Linux v2.26.02.014.
[    3.728014] scsi6 : 3ware 9000 Storage Controller
[    3.728087] 3w-9xxx: scsi6: Found a 3ware 9000 Storage Controller at 0xfebffc00, IRQ: 16.

The tw_cli software from 3ware has to be installed in order to get information
about the hard disks. Add the following software repository.
  # 3Ware
  deb http://jonas.genannt.name/debian lenny restricted
# sudo vi /etc/apt/sources.list
[sudo] password for user:
# su - root
Password:
# wget -O - http://jonas.genannt.name/debian/jonas_genannt.pub | apt-key add -
# logout
# sudo apt-get update
[sudo] password for user:
# apt-cache search 3ware
3ware-3dm2-binary - 3ware 3DM 2 Disk Management Utility
3ware-cli-binary - Command Line Interface for 3Ware Controllers
# sudo apt-get install 3ware-cli-binary
[sudo] password for user:

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
[sudo] password for user: 
//server> info

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

//server> info c6

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

Port   Status           Unit   Size        Blocks        Serial
---------------------------------------------------------------
p0     OK               u1     931.51 GB   1953525168    6VP2C06R            
p1     OK               u1     931.51 GB   1953525168    5VP3BXFE            
p2     OK               u0     931.51 GB   1953525168    5VP3DWT8            
p3     OK               u0     931.51 GB   1953525168    6VP3Z1MQ            
p4     OK               u0     931.51 GB   1953525168    6VP256AZ            
p5     OK               u0     931.51 GB   1953525168    5VP1YBVN            
p6     OK               u0     931.51 GB   1953525168    5VP1YBR9            
p7     OK               u2     931.51 GB   1953525168    6VP2PC27            

//server> info c6 p0 model
/c6/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 3dm2 package.
# apt-cache search 3ware
3ware-3dm2-binary - 3ware 3DM 2 Disk Management Utility
3ware-cli-binary - Command Line Interface for 3Ware Controllers
# sudo apt-get install 3ware-3dm2-binary
[sudo] password for user:

Enable the 3dm2 service so that it will start when the system starts up.
# sudo update-rc.d 3dm2 enable
[sudo] password for user:

The 3dm2 service has already been started as part of the installation process.
# pgrep 3dm2
6372
6373
6374

Modify the configuration file for 3dm2. The default password for the
Administrator user is 3ware.
  RemoteAccess 1
# sudo cp /etc/3dm2/3dm2.conf /etc/3dm2/3dm2.conf.example
[sudo] password for user: 
# sudo vi /etc/3dm2/3dm2.conf
[sudo] password for user: 
# sudo service 3dm2 restart
[sudo] password for user:


3 - Smartmontools installation

Install the smartmontools package.
# sudo apt-get install smartmontools
[sudo] password for user:


4 - Service configuration

Find where the smartmontools daemon was installed to.
# apt-file update
# apt-file list smartmontools | awk '{print $2}' | grep sbin
/usr/sbin/smartctl
/usr/sbin/smartd
/usr/sbin/update-smart-drivedb

Edit the default options file to have the following.
  smartd_opts="-p /var/run/smartd.pid -q never"
# sudo vi /etc/default/smartmontools
[sudo] password for user: 

Enable the smartmontools service so that it will start when the system
starts up.
  start_smartd=yes
# sudo vi /etc/default/smartmontools
[sudo] password for user:

Find where the configuration file should be put.
# grep smartd.conf /etc/init.d/smartd
    config=/etc/smartd.conf
            echo -n "Reloading smartd configuration: "
    SMARTD_CONFIG=/etc/smartd.conf
            echo -n "Reloading smartd configuration: "
# strings /usr/sbin/smartd | grep smartd.conf
/etc/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
  /dev/twa0 -d 3ware,3 -S off -s S/../.././20 -m notifications@test.com -a
  /dev/twa0 -d 3ware,4 -S off -s S/../.././20 -m notifications@test.com -a
  /dev/twa0 -d 3ware,5 -S off -s S/../.././20 -m notifications@test.com -a
  /dev/twa0 -d 3ware,6 -S off -s S/../.././20 -m notifications@test.com -a
# apt-file list smartmontools | awk '{print $2}' | grep smartd.conf
/etc/smartd.conf
/usr/share/doc/smartmontools/smartd.conf.gz
/usr/share/man/man5/smartd.conf.5.gz
# sudo cp /etc/smartd.conf /etc/smartd.conf.example
[sudo] password for user:
# sudo vi /etc/smartd.conf
[sudo] password for user:

Start the smartmontools service.
# sudo service smartd start
[sudo] password for user:
Starting S.M.A.R.T. daemon: smartd.
# sudo service smartd status
[sudo] password for user:
/usr/sbin/smartd is running.


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
[sudo] password for user: 
smartctl 5.41 2011-06-09 r3365 [i686-linux-3.3.6-030306-generic-pae] (local build)
Copyright (C) 2002-11 by Bruce Allen, 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   
[sudo] password for user:
smartctl 5.41 2011-06-09 r3365 [i686-linux-3.3.6-030306-generic-pae] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Barracuda 7200.12
Device Model:     ST31000528AS
Serial Number:    6VP2C06R
LU WWN Device Id: 5 000c50 01ec7472a
Firmware Version: CC38
User Capacity:    1,000,204,886,016 bytes [1.00 TB]
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  ATA-8-ACS revision 4
Local Time is:    Sun Jun  3 21:15:50 2012 CDT
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
[sudo] password for user:
smartctl 5.41 2011-06-09 r3365 [i686-linux-3.3.6-030306-generic-pae] (local build)
Copyright (C) 2002-11 by Bruce Allen, 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
[sudo] password for user:
smartctl 5.41 2011-06-09 r3365 [i686-linux-3.3.6-030306-generic-pae] (local build)
Copyright (C) 2002-11 by Bruce Allen, 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 Jun  3 21:18:39 2012

Use smartctl -X to abort test.

This command lists the log of selftest results.
# sudo smartctl -d 3ware,0 /dev/twa0 -l selftest
[sudo] password for user: 
smartctl 5.41 2011-06-09 r3365 [i686-linux-3.3.6-030306-generic-pae] (local build)
Copyright (C) 2002-11 by Bruce Allen, 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%     20743         -


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 Mythbuntu.
# sudo shutdown -r now
[sudo] password for user: 
# pgrep 3dm2
1364
1404
1405
# sudo service smartd status
[sudo] password for user:
/usr/sbin/smartd is running.


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