LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices

Reply
 
Search this Thread
Old 12-13-2012, 08:59 PM   #1
stoat
Member
 
Registered: May 2007
Distribution: LFS
Posts: 464

Rep: Reputation: 133Reputation: 133
Smartmontools in BLFS


Smartmontools is a maintained and up-to-date package of applications for controlling and monitoring the S.M.A.R.T. data from hard drives. I find this to be useful. I always installed it mainline distros. I also install it in BLFS. It is not in the book.


Two Components

smartctl is a command line utility that can control and monitor the S.M.A.R.T. data from hard drives. See its man page. I use it to display the results of hard drive self tests every now and then. I like to redirect those results to a text file that I keep and compare to later ones to look for changes that might predict failure of my hard drives.
example_self_test.txt
smartd is the daemon that can be started via an init script and monitor hard drives in the background if that is desired. Its config file is smartd.conf and is where to specify what and how it monitors. It also can be configured to mail messages about critical changes (if mail stuff is running, of course). The supplied smartd.conf file is self-documenting, but there is also a smartd.conf man page. Like almost any config file, it's intimidating at first. After staring at it for a while, I understood how it works. It comes with most everything commented out. I ended up commenting out the one uncommented DEVICESCAN line and adding a single line at the end for the one drive in this computer.
/dev/sda -d ata -o on -S on -a -m root@localhost.localdomain

Installation

This is straightforward and described in the INSTALL file. I install it this way...
Code:
./configure --prefix=/usr                         \
            --sysconfdir=/etc                     \
            --without-selinux                     \
            --with-initscriptdir=/etc/rc.d/init.d &&
make
As root...
Code:
make install
That installs the executables and the init script. But it does not create runlevel symlinks. I do that manually...
Code:
ln -sv ../init.d/smartd /etc/rc.d/rc0.d/K40smartd
ln -sv ../init.d/smartd /etc/rc.d/rc1.d/K40smartd
ln -sv ../init.d/smartd /etc/rc.d/rc2.d/S50smartd
ln -sv ../init.d/smartd /etc/rc.d/rc3.d/S50smartd
ln -sv ../init.d/smartd /etc/rc.d/rc4.d/S50smartd
ln -sv ../init.d/smartd /etc/rc.d/rc5.d/S50smartd
ln -sv ../init.d/smartd /etc/rc.d/rc6.d/K40smartd

The Init Script

It's named smartd and it has a bunch of lines for devining what the distro is so it can start and stop the smartd daemon appropriately for that distro. Obviously, none of that stuff is relevant to us. It also sources /etc/init.d/functions, which we have and will work, but it's more appropriate and esthetic for it to source /lib/lsb/init-functions like all our other init scripts. Starting with the provided init script, I edited it down to a few simple lines to start, stop, and restart...
Code:
cat > /etc/rc.d/init.d/smartd << "EOF"
#!/bin/sh
########################################################################
# Begin smartd
#
# Description : Self Monitoring and Reporting Technology (SMART) Daemon
#
# Authors     : Adapted from the original by me
#
# Update      :
#
# Version     : LFS 7.2
#
########################################################################

### BEGIN INIT INFO
# Provides:            smartd
# Required-Start:      $syslog $remote_fs
# Should-Start:        sendmail
# Required-Stop:       $syslog $remote_fs
# Should-Stop:         sendmail
# Default-Start:       2 3 4 5
# Default-Stop:        0 1 6  
# Short-Description:   Monitors disk and tape health via S.M.A.R.T.
# Description:         smartd is a daemon that monitors the Self-Monitoring,
#                      Analysis, and Reporting Technology (S.M.A.R.T.) system
#                      built into many hard drives. The purpose of S.M.A.R.T.
#                      is to monitor the reliability of the hard drive,
#                      predict drive failure, and to perform various tests.
# X-LFS-Provided-By:   LFS
### END INIT INFO

. /lib/lsb/init-functions

SMARTD_ARGS=

# Sort out the executable to run...
if [ -x /usr/sbin/smartd ]; then
   SMARTD_BIN=/usr/sbin/smartd
elif [ -x /usr/local/sbin/smartd ]; then
   SMARTD_BIN=/usr/local/sbin/smartd
else
   echo "$0: Can't find location of smartd binary, aborting."
   exit 1
fi

case "$1" in
   start)
      log_info_msg "Starting smartd... "
      $SMARTD_BIN ${SMARTD_ARGS}
      evaluate_retval
      ;;

   stop)
      log_info_msg "Stopping smartd... "
      killproc $SMARTD_BIN
      evaluate_retval
      ;;

   restart)
      $0 stop
      sleep 1
      $0 start
      ;;

   *)
      echo $"Usage: $0 {start|stop|restart}"
      exit 1
esac

# End /etc/init.d/smartd
EOF
chmod 754 /etc/rc.d/init.d/smartd

Conclusion

Smartmontools is worth considering IMO, but no promises for anything above this sentence. My runlevel symlinks may not be what others want. And I guess everybody knows to create a tarball backup before installing anything new.


Some References and the Download Site
http://sourceforge.net/projects/smartmontools/files/
http://sourceforge.net/apps/trac/smartmontools/wiki
http://en.wikipedia.org/wiki/Smartmontools
http://smartmontools.sourceforge.net...martctl.8.html
http://smartmontools.sourceforge.net/man/smartd.8.html
http://smartmontools.sourceforge.net...td.conf.5.html

Last edited by stoat; 12-14-2012 at 08:13 AM.
 
Old 12-15-2012, 08:24 AM   #2
Keith Hedger
Member
 
Registered: Jun 2010
Location: Devon,UK
Distribution: Linux From Scratch, Slackware64,
Posts: 832

Rep: Reputation: 167Reputation: 167
Thanks for this, I won't put it in my main LFS but it will go into my rescue/backup LFS
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Smartmontools: Ya Mon! LXer Syndicated Linux News 0 05-21-2010 03:10 AM
smartmontools gives a 0 lifetime. What does it mean? konqi Linux - Hardware 5 08-22-2009 10:42 AM
don't know how to run smartmontools newbiesforever Linux - Software 4 12-03-2008 01:18 PM
smartmontools shawniecas Linux - Newbie 2 06-11-2007 11:58 AM
smartmontools shawniecas Linux - Software 1 06-11-2007 09:54 AM


All times are GMT -5. The time now is 05:41 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration