summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRudd-O <rudd-o@rudd-o.com>2016-10-17 18:51:15 +0000
committerBrian Behlendorf <behlendorf1@llnl.gov>2016-10-17 18:51:15 +0000
commitf8e87e205c745c1e360230ac9c7631eb4632acfa (patch)
tree57dc7fb26c0d7a1ce2f5fd6d97a2c674c69c6966
parentfea33e4e5010e209a4d05fa3f59b7155859e1593 (diff)
-rw-r--r--contrib/dracut/90zfs/Makefile.am2
-rwxr-xr-xcontrib/dracut/90zfs/module-setup.sh.in1
-rwxr-xr-xcontrib/dracut/90zfs/mount-zfs.sh.in2
-rw-r--r--contrib/dracut/90zfs/zfs-needshutdown.sh.in10
4 files changed, 13 insertions, 2 deletions
diff --git a/contrib/dracut/90zfs/Makefile.am b/contrib/dracut/90zfs/Makefile.am
index 2777a8142768..243a5200fa1e 100644
--- a/contrib/dracut/90zfs/Makefile.am
+++ b/contrib/dracut/90zfs/Makefile.am
@@ -5,6 +5,7 @@ pkgdracut_SCRIPTS = \
mount-zfs.sh \
parse-zfs.sh \
zfs-generator.sh \
+ zfs-needshutdown.sh \
zfs-lib.sh
EXTRA_DIST = \
@@ -13,6 +14,7 @@ EXTRA_DIST = \
$(top_srcdir)/contrib/dracut/90zfs/mount-zfs.sh.in \
$(top_srcdir)/contrib/dracut/90zfs/parse-zfs.sh.in \
$(top_srcdir)/contrib/dracut/90zfs/zfs-generator.sh.in \
+ $(top_srcdir)/contrib/dracut/90zfs/zfs-needshutdown.sh.in \
$(top_srcdir)/contrib/dracut/90zfs/zfs-lib.sh.in
$(pkgdracut_SCRIPTS):%:%.in
diff --git a/contrib/dracut/90zfs/module-setup.sh.in b/contrib/dracut/90zfs/module-setup.sh.in
index 240847a77c72..a653b50f4bc6 100755
--- a/contrib/dracut/90zfs/module-setup.sh.in
+++ b/contrib/dracut/90zfs/module-setup.sh.in
@@ -58,6 +58,7 @@ install() {
inst_script "${moddir}/zfs-generator.sh" "$systemdutildir"/system-generators/dracut-zfs-generator
fi
inst_hook mount 98 "${moddir}/mount-zfs.sh"
+ inst_hook cleanup 99 "${moddir}/zfs-needshutdown.sh"
inst_hook shutdown 20 "${moddir}/export-zfs.sh"
inst_simple "${moddir}/zfs-lib.sh" "/lib/dracut-zfs-lib.sh"
diff --git a/contrib/dracut/90zfs/mount-zfs.sh.in b/contrib/dracut/90zfs/mount-zfs.sh.in
index db5ccddf2d90..e7f217736e24 100755
--- a/contrib/dracut/90zfs/mount-zfs.sh.in
+++ b/contrib/dracut/90zfs/mount-zfs.sh.in
@@ -22,7 +22,6 @@ if [ -e "$GENERATOR_FILE" -a -e "$GENERATOR_EXTENSION" ] ; then
# Let us tell the initrd to run on shutdown.
# We have a shutdown hook to run
# because we imported the pool.
- need_shutdown
# We now prevent Dracut from running this thing again.
for zfsmounthook in "$hookdir"/mount/*zfs* ; do
if [ -f "$zfsmounthook" ] ; then
@@ -60,7 +59,6 @@ if import_pool "${ZFS_POOL}" ; then
# Let us tell the initrd to run on shutdown.
# We have a shutdown hook to run
# because we imported the pool.
- need_shutdown
info "ZFS: Mounting dataset ${ZFS_DATASET}..."
if mount_dataset "${ZFS_DATASET}" ; then
ROOTFS_MOUNTED=yes
diff --git a/contrib/dracut/90zfs/zfs-needshutdown.sh.in b/contrib/dracut/90zfs/zfs-needshutdown.sh.in
new file mode 100644
index 000000000000..e3d1b59ccac9
--- /dev/null
+++ b/contrib/dracut/90zfs/zfs-needshutdown.sh.in
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+
+if zpool list 2>&1 | grep -q 'no pools available' ; then
+ info "ZFS: No active pools, no need to export anything."
+else
+ info "ZFS: There is an active pool, will export it."
+ need_shutdown
+fi