Using smartctl is widely described on the web for Linux and FreeBSD based environments, but it may be non-trivial in OpenBSD case.
This is because all of the disk operations are mostly inherited from 4.2BSD operating system.
As the usuals: partitions, filesystems and labeling are excellently described in OpenBSD Handbook I won’t cover that in following article.
Installation of smartmontools in OpenBSD 6.6
smartctl used for reading the S.M.A.R.T status of given storage device is fairly easy to install as it is a part of smartmontools package. All of the following commands are executed with root privileges.
mainframe# pkg_add smartmontools quirks-3.183 signed on 2020-03-22T11:47:19Z smartmontools-7.0p0: ok The following new rcscripts were installed: /etc/rc.d/smartd See rcctl(8) for details.
Next step is to enable the smartd daemon that monitors the devices.
mainframe# rcctl enable smartd mainframe#
Now the smartd should be added to rc.conf.
mainframe# cat /etc/rc.conf.local | grep smartd | wc -l 1
Finally we can run smartd without rebooting the machine.
mainframe# rcctl start smartd smartd(ok)
Three letters to rule it all
A key to running on the device of your choice is to know how OpenBSD mounts partitions in /dev. IDE devices are usually mounted with wd prefix, and SCSI devices with sd prefix. A key to run the smartctl tool is to know what each suffix letter stands for:
- a: the root partition of given disk,
- b: usually swap,
- c: whole disk - raw access.
The latter is to be used with smartctl tool.
mainframe# smartctl -i /dev/sd0c smartctl 7.0 2018-12-30 r4883 [x86_64-unknown-openbsd6.6] (local build) Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Device Model: INTEL SSDSC2KW128G8 Serial Number: … LU WWN Device Id: 5 5cd2e4 14f724e80 Firmware Version: LHF002C User Capacity: 128,035,676,160 bytes [128 GB] Sector Size: 512 bytes logical/physical Rotation Rate: Solid State Device Form Factor: 2.5 inches Device is: Not in smartctl database [for details use: -P showall] ATA Version is: ACS-3 (minor revision not indicated) SATA Version is: SATA 3.2, 6.0 Gb/s (current: 3.0 Gb/s) Local Time is: Sun Mar 22 23:57:21 2020 CET SMART support is: Available - device has SMART capability. SMART support is: Enabled
smartd status in the log
By default smartd polls the devices every 30 min and outputs its status in the /var/log/daemon log.