xref: /freebsd-14.2/libexec/rc/rc.d/zpool (revision d0b2dbfa)
174e2b24fSCy Schubert#!/bin/sh
274e2b24fSCy Schubert#
374e2b24fSCy Schubert#
474e2b24fSCy Schubert
574e2b24fSCy Schubert# PROVIDE: zpool
60cd66978SXin LI# REQUIRE: hostid disks
790802d88SXin LI# BEFORE: mountcritlocal
874e2b24fSCy Schubert# KEYWORD: nojail
974e2b24fSCy Schubert
1074e2b24fSCy Schubert. /etc/rc.subr
1174e2b24fSCy Schubert
1274e2b24fSCy Schubertname="zpool"
1374e2b24fSCy Schubertdesc="Import ZPOOLs"
1474e2b24fSCy Schubertrcvar="zfs_enable"
1574e2b24fSCy Schubertstart_cmd="zpool_start"
1674e2b24fSCy Schubertrequired_modules="zfs"
1774e2b24fSCy Schubert
1874e2b24fSCy Schubertzpool_start()
1974e2b24fSCy Schubert{
2074e2b24fSCy Schubert	local cachefile
2174e2b24fSCy Schubert
22a7841850SCy Schubert	for cachefile in /etc/zfs/zpool.cache /boot/zfs/zpool.cache; do
2374e2b24fSCy Schubert		if [ -r $cachefile ]; then
24*f30f11f8SChuck Tuffli			zpool import -c $cachefile -a -N
25*f30f11f8SChuck Tuffli			if [ $? -ne 0 ]; then
26*f30f11f8SChuck Tuffli				echo "Import of zpool cache ${cachefile} failed," \
27*f30f11f8SChuck Tuffli				    "will retry after root mount hold release"
28*f30f11f8SChuck Tuffli				root_hold_wait
29*f30f11f8SChuck Tuffli				zpool import -c $cachefile -a -N
30*f30f11f8SChuck Tuffli			fi
31*f30f11f8SChuck Tuffli			break
3274e2b24fSCy Schubert		fi
3374e2b24fSCy Schubert	done
3474e2b24fSCy Schubert}
3574e2b24fSCy Schubert
3674e2b24fSCy Schubertload_rc_config $name
3774e2b24fSCy Schubertrun_rc_command "$1"
38