This page looks best with JavaScript enabled

SmartMonTools on FreeBSD

 ·  🎃 kr0m

Monitoring the health of our disks is a very important task in order to anticipate failures in them, so we can make a backup of the data or even set up a spare equipment before the fateful day.

Smartmontools has the ability to perform certain tests, but we will only use the basic functionalities and configure it so that when it detects any problem, it informs us via email.

We install the software:

pkg install smartmontools

We enable the service at startup:

sysrc smartd_enable="yes"

We check the SCSI devices of the system:

camcontrol devlist

<WDC WDS120G2G0A-00JH30 UE510000>  at scbus0 target 0 lun 0 (ada0,pass0)  
<HL-DT-ST DVD+-RW GS20N A106>      at scbus1 target 0 lun 0 (cd0,pass1)  
<WD 0524AS External 1.75>          at scbus6 target 0 lun 0 (da0,pass2)

Another way to check the same information is through smartctl:

smartctl --scan

/dev/ada0 -d atacam # /dev/ada0, ATA device  
/dev/cd0 -d atacam # /dev/cd0, ATA device  
/dev/da0 -d sat # /dev/da0 [SAT], ATA device

We can see that we have two disks, one internal and one external.

We make a copy of the sample configuration file:

cp /usr/local/etc/smartd.conf.sample /usr/local/etc/smartd.conf

We configure smartmontool so that it does not scan the disks but only monitors the indicated ones and informs us via email:

vi /usr/local/etc/smartd.conf

#DEVICESCAN  
/dev/ada0 -H -C 0 -U 0 -m kr0m@alfaexploit.com  
/dev/da0 -d removable -H -C 0 -U 0 -m kr0m@alfaexploit.com

For the external disk, we had to add the removable parameter.

*removable - the device or its media is removable. This indicates to smartd that it should continue (instead of exiting, which is the default behavior) if the device does not appear to be present when smartd is started. This directive also suppresses warning emails and repeated log messages if the device is removed after startup.*

We start the service:

service smartd start

If you liked the article, you can treat me to a RedBull here