From 74e2b24f2c369ffdff2f54fa9f96427cc45ef3a6 Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Wed, 26 Aug 2020 13:13:57 +0000 Subject: As of r364746 (OpenZFS import) existing ZPOOLs are not imported prior to zvol and mountcritlocal resulting in ZVOLs (swap and virtual machine UFS filesystems) being unavailable, leading to boot failures. We move the zpool import from zfs to a new zpool script, with the -N option to avoid mounting datasets while making the ZPOOL's datasets available for "legacy" mount (mountpoint=legacy) and ZVOLs available for subsequent use for swap (in the zvol rc sript) or for UFS or other filesystems in fstab(5), mounted by mountcritlocal. Reviewed by: freqlabs (previous version) Differential Revision: https://reviews.freebsd.org/D26185 --- libexec/rc/rc.d/Makefile | 1 + libexec/rc/rc.d/mountcritlocal | 2 +- libexec/rc/rc.d/zfs | 7 ------- libexec/rc/rc.d/zpool | 31 +++++++++++++++++++++++++++++++ libexec/rc/rc.d/zvol | 2 +- 5 files changed, 34 insertions(+), 9 deletions(-) create mode 100755 libexec/rc/rc.d/zpool (limited to 'libexec/rc') diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile index 77499e483f0d0..7e0e63dae414f 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -318,6 +318,7 @@ CONFGROUPS+= ZFS ZFS+= zfs ZFS+= zfsbe ZFS+= zfsd +ZFS+= zpool ZFS+= zvol .endif diff --git a/libexec/rc/rc.d/mountcritlocal b/libexec/rc/rc.d/mountcritlocal index f52c565d65c6e..cfdc8041a8c7c 100755 --- a/libexec/rc/rc.d/mountcritlocal +++ b/libexec/rc/rc.d/mountcritlocal @@ -4,7 +4,7 @@ # # PROVIDE: mountcritlocal -# REQUIRE: root hostid_save mdconfig +# REQUIRE: root hostid_save mdconfig zvol # KEYWORD: nojail shutdown . /etc/rc.subr diff --git a/libexec/rc/rc.d/zfs b/libexec/rc/rc.d/zfs index 69e3ad5ce6718..2d35f9b54642e 100755 --- a/libexec/rc/rc.d/zfs +++ b/libexec/rc/rc.d/zfs @@ -25,13 +25,6 @@ zfs_start_jail() zfs_start_main() { - local cachefile - - for cachefile in /boot/zfs/zpool.cache /etc/zfs/zpool.cache; do - if [ -r $cachefile ]; then - zpool import -c $cachefile -a - fi - done zfs mount -va zfs share -a if [ ! -r /etc/zfs/exports ]; then diff --git a/libexec/rc/rc.d/zpool b/libexec/rc/rc.d/zpool new file mode 100755 index 0000000000000..01028f8633ead --- /dev/null +++ b/libexec/rc/rc.d/zpool @@ -0,0 +1,31 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: zpool +# REQUIRE: hostid +# BEFORE: zvol mountcritlocal +# KEYWORD: nojail + +. /etc/rc.subr + +name="zpool" +desc="Import ZPOOLs" +rcvar="zfs_enable" +start_cmd="zpool_start" +required_modules="zfs" + +zpool_start() +{ + local cachefile + + for cachefile in /boot/zfs/zpool.cache /etc/zfs/zpool.cache; do + if [ -r $cachefile ]; then + zpool import -c $cachefile -a -N + fi + done +} + +load_rc_config $name +run_rc_command "$1" diff --git a/libexec/rc/rc.d/zvol b/libexec/rc/rc.d/zvol index 06530347946ae..e8cfc203b481a 100755 --- a/libexec/rc/rc.d/zvol +++ b/libexec/rc/rc.d/zvol @@ -4,7 +4,7 @@ # # PROVIDE: zvol -# REQUIRE: hostid +# REQUIRE: zpool # BEFORE: dumpon # KEYWORD: nojail -- cgit v1.3