summaryrefslogtreecommitdiffstats
path: root/dracut/90zfs
diff options
context:
space:
mode:
authorLukas Wunner <[email protected]>2014-10-06 13:08:33 +0200
committerBrian Behlendorf <[email protected]>2014-10-07 10:20:56 -0700
commit07a3312f170ac56cb480b0df9fdf4c83f116b59b (patch)
tree7c12a27f405327a662ed1e34903cb0e8a9fb2219 /dracut/90zfs
parent8ac9b5e6b5b59ad3bf7a65f9de3c8ed46ba4240e (diff)
Amend Dracut module to export ZFS root on shutdown
Make use of Dracut's ability to restore the initramfs on shutdown and pivot to it, allowing for a clean unmount and export of the ZFS root. No need to force-import on every reboot anymore. Signed-off-by: Lukas Wunner <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #2195 Issue #2476 Issue #2498 Issue #2556 Issue #2563 Issue #2575 Issue #2600 Issue #2755 Issue #2766
Diffstat (limited to 'dracut/90zfs')
-rw-r--r--dracut/90zfs/.gitignore1
-rw-r--r--dracut/90zfs/Makefile.am2
-rwxr-xr-xdracut/90zfs/export-zfs.sh.in29
-rwxr-xr-xdracut/90zfs/module-setup.sh.in1
-rwxr-xr-xdracut/90zfs/mount-zfs.sh.in2
5 files changed, 35 insertions, 0 deletions
diff --git a/dracut/90zfs/.gitignore b/dracut/90zfs/.gitignore
index 6f4a5ae10..72a710a0e 100644
--- a/dracut/90zfs/.gitignore
+++ b/dracut/90zfs/.gitignore
@@ -1,3 +1,4 @@
+export-zfs.sh
module-setup.sh
mount-zfs.sh
parse-zfs.sh
diff --git a/dracut/90zfs/Makefile.am b/dracut/90zfs/Makefile.am
index 759aae81d..2d1360ade 100644
--- a/dracut/90zfs/Makefile.am
+++ b/dracut/90zfs/Makefile.am
@@ -1,10 +1,12 @@
pkgdracutdir = $(dracutdir)/modules.d/90zfs
pkgdracut_SCRIPTS = \
+ $(top_srcdir)/dracut/90zfs/export-zfs.sh \
$(top_srcdir)/dracut/90zfs/module-setup.sh \
$(top_srcdir)/dracut/90zfs/mount-zfs.sh \
$(top_srcdir)/dracut/90zfs/parse-zfs.sh
EXTRA_DIST = \
+ $(top_srcdir)/dracut/90zfs/export-zfs.sh.in \
$(top_srcdir)/dracut/90zfs/module-setup.sh.in \
$(top_srcdir)/dracut/90zfs/mount-zfs.sh.in \
$(top_srcdir)/dracut/90zfs/parse-zfs.sh.in
diff --git a/dracut/90zfs/export-zfs.sh.in b/dracut/90zfs/export-zfs.sh.in
new file mode 100755
index 000000000..dd1ea8121
--- /dev/null
+++ b/dracut/90zfs/export-zfs.sh.in
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+_do_zpool_export() {
+ local ret=0
+ local final=$1
+ local force
+
+ if [ "x$final" != "x" ]; then
+ force="-f"
+ fi
+
+ info "Exporting ZFS storage pools"
+ zpool list -H | while read fs rest ; do
+ zpool export $force "$fs" || ret=$?
+ done
+
+ if [ "x$final" != "x" ]; then
+ info "zpool list"
+ zpool list 2>&1 | vinfo
+ fi
+
+ return $ret
+}
+
+if command -v zpool >/dev/null; then
+ _do_zpool_export $1
+else
+ :
+fi
diff --git a/dracut/90zfs/module-setup.sh.in b/dracut/90zfs/module-setup.sh.in
index 6eb684381..2d0b335cf 100755
--- a/dracut/90zfs/module-setup.sh.in
+++ b/dracut/90zfs/module-setup.sh.in
@@ -39,6 +39,7 @@ install() {
dracut_install hostid
inst_hook cmdline 95 "$moddir/parse-zfs.sh"
inst_hook mount 98 "$moddir/mount-zfs.sh"
+ inst_hook shutdown 30 "$moddir/export-zfs.sh"
if [ -e @sysconfdir@/zfs/zpool.cache ]; then
inst @sysconfdir@/zfs/zpool.cache
diff --git a/dracut/90zfs/mount-zfs.sh.in b/dracut/90zfs/mount-zfs.sh.in
index 23ec7e45b..ca4e46614 100755
--- a/dracut/90zfs/mount-zfs.sh.in
+++ b/dracut/90zfs/mount-zfs.sh.in
@@ -67,5 +67,7 @@ case "$root" in
else
mount -o zfsutil -t zfs "$zfsbootfs" "$NEWROOT" && ROOTFS_MOUNTED=yes
fi
+
+ need_shutdown
;;
esac