...

How to check hard drive health on FreeBSD nixCraft

how-to-check-hard-drive-health-on-freebsd-nixcraft

How do I read my hard disk/SSD health using smartctl command on FreeBSD operating system? How can I hard drive health on FreeBSD and find out if my disk is dying?

The Self-Monitoring, Analysis, and Reporting Technology System (SMART) built into most modern hard disks. The purpose of SMART is to monitor the reliability of the hard drive and predict drive failures, and to carry out different types of drive self-tests under FreeBSD operating systems. This page shows how to install smartmontools on FreeBSD and use smartcl to check hard drive health on FreeBSD.

Install smartmontools on FreeBSD

Use FreeBSD ports system as follows to install the same:
# cd /usr/ports/sysutils/smartmontools
# make install clean

OR one can binary package system. Run the following pkg command:
# pkg install smartmontools

How to install smartmontools on FreeBSD to check hard disks
Installing smartmontools on FreeBSD using pkg

The smartmontools package contains two utility programs for FreeBSD:

  1. smartctl command – A command line tool to control and monitor hard disks health.
  2. smartd – It is a FreeBSD daemon that monitors hard disks health and alert users about problems using log files, email and more.

How to check hard drive health on FreeBSD

The syntax is as follows to check the status of drives:
smartctl -a /dev/disk
One can get a list all connected hard drives in FreeBSD by running the following commands:
# camcontrol devlist
OR use the grep command/egrep command as follows:
# egrep 'ad[0-9]|cd[0-9]' /var/run/dmesg.boot
egrep 'da[0-9]|cd[0-9]' /var/run/dmesg.boot

FreeBSD list all physical disk devices and logical units attached
FreeBSD listing all physical devices and logical units attached

FreeeBSD hard drive health checkups

Now you know hard disk device named on FreeBSD. Therefore, it is time to check hard disk information, run:
# smartctl -i /dev/ada0
Sample outputs:

smartctl 7.0 2018-12-30 r4883 [FreeBSD 11.2-RELEASE-p10 amd64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION ===
Model Family: Western Digital Red
Device Model: WDC WD60EFRX-68MYMN1
Serial Number: WD-XXXXXXXXXXXXXXX
LU WWN Device Id: 5 0014ee 26195240d
Firmware Version: 82.00A82
User Capacity: 6,001,175,126,016 bytes [6.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5700 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-2, ACS-3 T13/2161-D revision 3b
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Mon May 20 22:53:06 2019 IST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Check disk health, run:
# smartctl -a /dev/ada0
Sample session:

smartctl 7.0 2018-12-30 r4883 [FreeBSD 11.2-RELEASE-p10 amd64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION ===
Model Family: HGST Deskstar NAS
Device Model: HGST YYYYYYYYYZZZ
Serial Number: K1JVDUGD
LU WWN Device Id: 5 000cca 255e830c9
Firmware Version: APGNW7JH
User Capacity: 6,001,175,126,016 bytes [6.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 7200 rpm
Form Factor: 3.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-2, ATA8-ACS T13/1699-D revision 4
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Mon May 20 23:00:59 2019 IST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled === START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 1 Raw_Read_Error_Rate 0x000b 100 100 016 Pre-fail Always - 0 2 Throughput_Performance 0x0005 138 138 054 Pre-fail Offline - 100 3 Spin_Up_Time 0x0007 149 149 024 Pre-fail Always - 436 (Average 449) 4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 43 5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0 7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0 8 Seek_Time_Performance 0x0005 128 128 020 Pre-fail Offline - 18 9 Power_On_Hours 0x0012 099 099 000 Old_age Always - 8501 10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 42 192 Power-Off_Retract_Count 0x0032 095 095 000 Old_age Always - 6673 193 Load_Cycle_Count 0x0012 095 095 000 Old_age Always - 6673 194 Temperature_Celsius 0x0002 117 117 000 Old_age Always - 51 (Min/Max 25/52) 196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0 197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0 198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0 199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0 SMART Error Log Version: 1
No Errors Logged SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t] SMART Selective self-test log data structure revision number 1 SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS 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.

If you see Reallocated or Pending sectors, replace that hard drive ASAP.

How to configure smartd to get email alert

Edit the file as following using the vim command:
# cd /usr/local/etc
# cp smartd.conf.sample smartd.conf
# vim smartd.conf

First, comment out or delete all DEVICESCAN lines:
# DEVICESCAN
Next explicitly list the devices that you wish to monitor. For example:
/dev/ada0 -a -m disk.admin@your-tld
Add all of your disks too:
/dev/ada1 -a -m disk.admin@your-tld,root@localhost
See smartd.conf man page for more info. Make sure smartd start at boot time, run:
echo 'smartd_enable="YES"' >> /etc/rc.conf

Start/stop/restart the service

# service smartd start
# service smartd restart
# service smartd status
# service smartd stop

Conclusion

This page explained how to check hard drive disk health in FreeBSD operating system using command line tool and smartd service. It is essential that you always keep backup of all critical data. For further info see:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Discover more from WIREDGORILLA

Subscribe now to keep reading and get access to the full archive.

Continue reading