Child pages
  • Install smartmontools on Citrix XenServer
Skip to end of metadata
Go to start of metadata

Every professionally used server should have its disk drives monitored. It is a bit surprising that smartmontools are not installed by default on Citrix XenServer, but fortunately this is easy to fix.

Disk drives will eventually fail! Do use smartmontools!

I am running smartmontools for a few years now, and I have already received several warning emails about failing disk drives. Often, if you know that a disk drive is about to fail, you still have time to gracefully shut down virtual machines, run backups etc.

Installing and configuring smartmontools on Citrix XenServer (or any other Linux system) is trivial and absolutely worth the time.

General installation

To install smartmontools on a general Linux system (not XenServer), run

yum install smartmontools


apt-get install smartmontools

Installation on Citrix XenServer

Citrix XenServer 5.5, 5.6 and 6.0 are based on CentOS 5.4, but the smartmontools package is not available in the default Citrix repository, so it can't be installed with yum install smartmontools (as it would be possible with any other CentOS distribution).

It is probably safest to use the same versions that were in the original CentOS 5.4 distribution. Since that release is no longer the latest, we have to go to an archive server to find the packages. The packages listed below are actually used in other CentOS releases too, so these are probably the latest versions anyway.



rpm -hiv smartmontools-5.38-2.el5.i386.rpm mailx-8.1.1-44.2.2.i386.rpm
warning: smartmontools-5.38-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:mailx                  ########################################### [ 50%]
   2:smartmontools          ########################################### [100%]

Checking the disk status

We can now retrieve the disk status using smartctl -d ata -a /dev/sda. The most important fields are : SMART overall-health self-assessment test result - that should always have a value of PASSED. Other important fields are:

  • Reallocated_Sector_Ct, which counts the number of bad blocks that have been reallocated. It should be a low number. If this value increases, it is an alarm signal. Make a backup and replace the disk drive.
  • Current_Pending_Sector, which is the number of blocks with read errors that are not yet reallocated.
  • Offline_Uncorrectable .

Also check out the columns VALUE WORST THRESH. For each attribute, the current value of the field should never be lower than the threshold defined by the manufacturer.

smartctl -d ata -a /dev/sda
smartctl version 5.38 [i686-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is

Device Model:     ST31500341AS
Serial Number:    9VS1Y9GE
Firmware Version: CC1H
User Capacity:    1,500,301,910,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:    Wed Mar  2 22:37:23 2011 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x82) Offline data collection activity
                                        was completed without error.
                                        Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                 ( 625) seconds.
Offline data collection
capabilities:                    (0x7b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   1) minutes.
Extended self-test routine
recommended polling time:        ( 255) minutes.
Conveyance self-test routine
recommended polling time:        (   2) minutes.
SCT capabilities:              (0x103f) SCT Status supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
  1 Raw_Read_Error_Rate     0x000f   108   099   006    Pre-fail  Always       -       20188464
  3 Spin_Up_Time            0x0003   100   100   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       5
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       2
  7 Seek_Error_Rate         0x000f   083   060   030    Pre-fail  Always       -       212504152
  9 Power_On_Hours          0x0032   083   083   000    Old_age   Always       -       14961
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       5
184 Unknown_Attribute       0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
188 Unknown_Attribute       0x0032   100   098   000    Old_age   Always       -       29
189 High_Fly_Writes         0x003a   001   001   000    Old_age   Always       -       143
190 Airflow_Temperature_Cel 0x0022   064   050   045    Old_age   Always       -       36 (Lifetime Min/Max 22/47)
194 Temperature_Celsius     0x0022   036   050   000    Old_age   Always       -       36 (0 19 0 0)
195 Hardware_ECC_Recovered  0x001a   049   011   000    Old_age   Always       -       20188464
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       43379169704557
241 Unknown_Attribute       0x0000   100   253   000    Old_age   Offline      -       3426517151
242 Unknown_Attribute       0x0000   100   253   000    Old_age   Offline      -       6452474

SMART Error Log Version: 1
No Errors Logged

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%     14961         -

SMART Selective self-test log data structure revision number 1
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

Running tests manually

To test a drive, issue either a short (smartctl -d ata -t short /dev/sda) or a long (smartctl -d ata -t long /dev/sda) internal self test. These tests are not destructive and can be executed during normal usage. A short test will complete in a couple of minutes, while a long test can run for hours.

smartctl -d ata -t long /dev/sda
smartctl version 5.38 [i686-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is

Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 255 minutes for test to complete.
Test will complete after Fri Mar  4 12:45:52 2011

Use smartctl -X to abort test.

Check the disk status with smartctl -d ata -a /dev/sda after the self-test completes.

Automatic monitoring of disk drives

The smartd daemon handles automatic testing for all drives, logs any status changes in /var/log/syslog or /var/log/messages and sends a status email in case of a problem (if mail es enabled, see below). It is configured in the file /etc/smartd.conf.

The following lines will run a short test every day between 02:00 and 03:00, and a long test on every Saturday between 03:00 and 04:00. If there is a problem, send an email to the configured address. The -M test option will send a test email whenever the smartd daemon is started.

The DEVICESCAN line would normally cause default test runs for all disks that smartd finds, but does not work on my system for some reason. So it is commented out and the tests will only run for explicitly listed devices.

/dev/sda -d ata -a -s (S/../.././02|L/../../6/03) -t -m
/dev/sdb -d ata -a -s (S/../.././02|L/../../6/03) -t -m

#DEVICESCAN -H -m root

After any change to the /etc/smartd.conf file the smartd daemon should be restarted: /etc/init.d/smartd restart

Enabling email on Citrix XenServer

Citrix XenServer is not configured to run a mail server. Therefore without further configuration smartd might attempt to send out warning emails in case anything fails, but no mails will actually receive their destination.

It is fortunately not necessary to install a full-blown email package. XenServer comes with ssmtp preinstalled, which simply forwards emails to a real mail server.

To enable mail sending on Citrix XenServer, set up /etc/ssmtp/ssmtp.conf. You need to provide a real mail server and the local domain name.

# /etc/ssmtp.conf -- a config file for sSMTP sendmail.

After setting up /etc/ssmtp/ssmtp.conf, send a test email from the console to make sure that the email gets through:

echo "this is a test mail" | mailx -s "Test mail"

If you are using the -M test option to a /etc/smartd.conf device definition, you can also restart the smartd daemon to have it send out test emails.

See also

Monitoring Hard Disks with SMART
smartmontools Website
Festplatten mit SMART überwachen


  1. Anonymous

    This is by far the best tutorial for xenserver I have used in a long time.  I have spent untold hours trying to set up nagios with one of the main purposes being monitoring the local hard drives.  I could never get it set up to really do what it needed to.  I am very glad I found this.  Thank you so much!!

  2. Anonymous

    this version does not work with LSI controllers. From what i can understand you need at least version 5.39.

    Can someone kindly provide a link to this version for use in Xenserver 6.0?



    1. I did not find smartmontools 5.39 in a package for CenOS 5.x, only for CentOS 6. Maybe a Fedora package works with XenServer. If all else fails, you could download the source code (SRPM) and build your own smartmontools package.

      Here is a list of all kinds of smartmontools packages:

      1. Anonymous

        Thank you Arne

        I wish it was that simple! but although i can install and administer Xenserver, i am still a newbie with Linux.This post was perfect, all worked well but not suitable for LSI cards, so maybe there is a volunteer out their to update it with a later smartmon version.

        When i tried, i kept getting failures due to dependencies and the list is quite long.

        Would appreciate any help you can offer.



        1. I have now created a package that works with LSI controllers: see Configuring smartmontools for LSI 9750 RAID Controller on XenServer.

          1. Anonymous

            Hello Arne,

            I found your articles and have tried to get the SMART going on my Citrix Xenserver.
            But it comes with SMART not supported, but it should be supported by this controller MegaRAID 8704EM2

            Question, is this controller in your package?

            Any help much appreciated



            Hardware info:

            Citrix  XenServer 5.6.0-31188p

            In console, RAID bus controller, MegaRAID SAS 1078

            [root@server ~]# smartctl -a /dev/sda
            smartctl 5.42 2011-10-20 r3458 [i686-linux-] (local build)
            Copyright (C) 2002-11 by Bruce Allen,

            Vendor:               LSI     
            Product:              MegaRAID 8704EM2
            Revision:             1.40
            User Capacity:        1,998,912,094,208 bytes [1.99 TB]
            Logical block size:   512 bytes
            Logical Unit id:      0x600605b001b679b013c0e6474c8fdef0
            Serial number:        00f0de8f4c47e6c013b079b601b00506
            Device type:          disk
            Local Time is:        Wed Feb  8 14:06:14 2012 GMT
            Device does not support SMART

            Error Counter logging not supported
            Device does not support Self Test logging


            1. Anonymous

              Hi Arne,

              I found the information of the devices in a previous screenshot I made of the server.
              Device IDs are 4,5,6,7, using megaraid did not work and suggested to use the buggy sat+megaraid.

              This now shows the following information.

               smartctl -i -d sat+megaraid,4 /dev/sda
              smartctl 5.42 2011-10-20 r3458 [i686-linux-] (local build)
              Copyright (C) 2002-11 by Bruce Allen,

              === START OF INFORMATION SECTION ===
              Model Family:     Western Digital RE4-GP
              Device Model:     WDC WD2002FYPS-01U1B1
              Serial Number:    WD-WCAVY4062234
              LU WWN Device Id: 5 0014ee 259e46bc3
              Firmware Version: 04.05G05
              User Capacity:    2,000,398,934,016 bytes [2.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:  Exact ATA specification draft version not indicated
              Local Time is:    Sun Feb 12 21:48:31 2012 GMT
              SMART support is: Available - device has SMART capability.
              SMART support is: Enabled

              A small step further...

              Not sure how to build up the smartd.conf file to get an email if there is a problem with the disk.
              Any idea?


              Many thanks.

              1. If the MegaRAID 8704EM2 controller is supported by smartmontools-5.42, then it should be also supported by the smartmontools package for XenServer that you can download here. But I don't have the controller available so I can't test it. Let me know if you get it working.

                1. Anonymous

                  Hi Arne, I got it installed and modified the smartd.conf

                  vi /etc/smartd.conf

                  /dev/sda -d sat+megaraid,4 -a -s S/../.././6 -t -m email@address repeated for each drive.

                  However I noticed a real performance issue, not sure if it was down to the test on each drive or just that smartd was not running very well with my Citrix Xenserver version.
                  Because I had it running on a production server I had to remove it to get the performance back.

                  No idea why it caused this performance issue (sad)

                  Not sure now how to monitor my drives now for failure..


  3. Anonymous

    Hey Arne, Great info. I'm curious, how difficult was it to build and could you offer some tips. I'd like to build 5.43 version is possible.



  4. Anonymous

    installing smartmontools on xenserver:

    yum --enablerepo=base install smartmontools