How to automatically detect inserted SATA disk in Solaris if cfgadm status is disconnected?

Onboard Sata/AHCI is hotplug capable but this is disabled in OmniOS per default: To enable add the following line to /etc/system

set sata:sata_auto_online=1


Interesting question... a bit of a science experiment, as I'd probably just use USB or send remotely or have this on a schedule...

But in your case, I wouldn't try to "look" for the disk at all from a cfgadm or log parsing manner. That's not scalable.

I'd simply name the removable disk with a unique ZFS pool name and script logic around a periodic zpool import. In ZFS under Linux, the pool import process is a systems service/daemon. But there's no cost to running it periodically. It'll detect the drive and associated pool.

I hope you're exporting the pool when you're done with the backup as well. That would cover situations where the drive remains in the server for multiple backup cycles. Like leaving a backup tape in its drive.


I'll add this answer to document what I found out about monitoring events (may also be useful in other cases):

While trying to ask the question on unix/linux.SE, I noticed a useful thread about using udev on Linux to monitor for kernel events. As an equivalent tools for Solaris, I stumbled upon the suggestion to use syseventadm which watches for sysevents and triggers defined actions/scripts.


At first I did not find much except copies of the man page and some discussions about a problem with Xen Hypervisor, but the supported events are listed in /usr/include/sys/sysevent/eventdefs.h (or online at /usr/src/uts/common/sys/sysevent/eventdefs.h in various repos) and other files in that directory.

Using the first example from the manpage and syseventadm add -c EC_zfs -s ESC_ZFS_scrub_start /path/to/script.sh \$pool_name I successfully tested a sample event that fires every time a scrub is initiated and returns the pool name as first argument.


After some trial and error, I found the correct way to monitor for newly added disks:

syseventadm add -c EC_dev_add -s disk /path/to/script.sh \$version \$dev_name \$phys_path \$driver_name \$instance
syseventadm restart

Everything after disk is optional and directly passed to the script as arguments $1 to $5.

Now as soon as the newly added disk comes online, the script will be triggered and the script can check if the device ID is correct (optional) and then import the pool by name.