FreeBSD Port: smartmontools-6.2_2

Karli Sjöberg Karli.Sjoberg at
Thu Mar 20 09:56:57 UTC 2014


I´m sending this email to you because you are listed as maintainer of
the 'smartmontools' port.

I´ve been using smart daemon for long time but I´ve never been able to
use 'daily_status_smart_devices="auto"' in '/etc/periodic.conf' because
there are USB drives attached and smartctl can´t handle them, at least
not by default:
# camcontrol devlist
<ATA ST3000DM001-1CH1 CC24>        at scbus0 target 0 lun 0 (da0,pass0)
<ATA ST3000DM001-1CH1 CC24>        at scbus0 target 1 lun 0 (da1,pass1)
<ATA ST3000DM001-1CH1 CC24>        at scbus0 target 2 lun 0 (da2,pass2)
<ATA ST3000DM001-1CH1 CC24>        at scbus0 target 3 lun 0 (da3,pass3)
<ATA WDC WD30EFRX-68E 0A80>        at scbus0 target 5 lun 0 (pass4,da4)
<Kingston DT Micro 1.00>           at scbus6 target 0 lun 0 (da5,pass5)
<Kingston DT Micro 1.00>           at scbus7 target 0 lun 0 (da6,pass6)
# smartctl -H /dev/da5; echo $?
smartctl 6.2 2014-02-18 r3874 [FreeBSD 9.2-RELEASE amd64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke,

/dev/da5: Unknown USB bridge [0x0951:0x168a (0x100)]
Please specify device type with the -d option.

Use smartctl -h to get a usage summary


So I´ve been looking at '/usr/local/etc/periodic/daily/smart', thinking
about a "smart" way to sort that out:) So if the script was to loop
through the disks in "sysctl -n kern.disks | sed -E 's/[[:<:]](cd|
ar)[0-9]+//g'" and compare with 'camcontrol devlist' for known types of
hard drives like ATA, SAS and SCSI to determine if it´s a "real" hard
drive or not, that would fix the problem. It could also have support for
recognizing virtual qemu hard drives because they too show up in 'sysctl
-n kern.disks'. Who knows, maybe smartctl will support that as well in
the future:) And then I made a patch that does that.

--- smart.orig	2014-03-20 09:50:36.495362586 +0100
+++	2014-03-20 10:34:49.775232517 +0100
@@ -16,7 +16,19 @@
 case "${daily_status_smart_devices}" in
 	# XXX AUTO mode selects only regular ad/da disks 
-		daily_status_smart_devices="$(sysctl -n kern.disks | sed -E 's/[[:<:]](cd|ar)[0-9]+//g')"
+                # Filter out USB drives as well
+                for DISK in $(sysctl -n kern.disks | sed -E 's/[[:<:]](cd|ar)[0-9]+//g'); do
+                  HDD=$(camcontrol devlist | egrep "\(${DISK},|,${DISK}\)" | egrep '(ATA|SAS|SCSI|QEMU HARDDISK)' | awk 'END{print NR}')
+                  if [ ${HDD} -ne "0" ]; then
+                    HDDS="${HDDS} ${DISK}"
+                  else
+                    DEVICE_NUMBER=$(echo ${DISK} | awk '{gsub(/[a-zA-Z]/, ""); print}')
+                    if [ $(grep "vtblk${DEVICE_NUMBER}" /var/run/dmesg.boot | awk 'END{print NR}') -ne "0" ]; then
+                      HDDS="${HDDS} ${DISK}"
+                    fi
+                  fi
+                done
+                daily_status_smart_devices=$(echo ${HDDS} | sed 's/^ //')
 	*)	;;

If you like it, please consider using it for the port and I would
finally be able to just say "auto" without having any issues with my USB
drives any more. The patch is also included as an attachment.

Karli Sjöberg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smart.patch
Type: text/x-patch
Size: 1136 bytes
Desc: smart.patch
URL: <>

More information about the freebsd-ports mailing list