]> git.proxmox.com Git - mirror_zfs.git/commitdiff
dracut: 90zfs: respect zfs_force=1 on systemd systems
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Thu, 10 Jun 2021 16:26:37 +0000 (18:26 +0200)
committerGitHub <noreply@github.com>
Thu, 10 Jun 2021 16:26:37 +0000 (09:26 -0700)
On systemd systems provide an environment generator in order
to respect the zfs_force=1 kernel command line option.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11403
Closes #12195

contrib/dracut/90zfs/.gitignore
contrib/dracut/90zfs/Makefile.am
contrib/dracut/90zfs/import-opts-generator.sh.in [new file with mode: 0755]
contrib/dracut/90zfs/module-setup.sh.in
etc/systemd/system/zfs-import-cache.service.in
etc/systemd/system/zfs-import-scan.service.in

index dce24393479b0e21e2ab8c64b6e62c11b92a6221..cb84212f3a2aaa274559b68ca5cca3e3a3b37aa9 100644 (file)
@@ -1,11 +1,2 @@
-export-zfs.sh
-module-setup.sh
-mount-zfs.sh
-parse-zfs.sh
-zfs-generator.sh
-zfs-lib.sh
-zfs-load-key.sh
-zfs-needshutdown.sh
-zfs-env-bootfs.service
-zfs-snapshot-bootfs.service
-zfs-rollback-bootfs.service
+*.sh
+*.service
index ff3a2b27f24e029c8b9939f152d8d5ff76a36364..3f7050300994838229a5768af0c96136bce95911 100644 (file)
@@ -10,7 +10,8 @@ pkgdracut_SCRIPTS = \
        zfs-generator.sh \
        zfs-load-key.sh \
        zfs-needshutdown.sh \
-       zfs-lib.sh
+       zfs-lib.sh \
+       import-opts-generator.sh
 
 pkgdracut_DATA = \
        zfs-env-bootfs.service \
diff --git a/contrib/dracut/90zfs/import-opts-generator.sh.in b/contrib/dracut/90zfs/import-opts-generator.sh.in
new file mode 100755 (executable)
index 0000000..8bc8c9b
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+. /lib/dracut-zfs-lib.sh
+
+echo ZPOOL_IMPORT_OPTS="$ZPOOL_IMPORT_OPTS"
index 817da5b2b4a94ea32975d60c3135fdc0f9e4916d..a4b62da1f7423385fb01f030453c22d982764a28 100755 (executable)
@@ -104,29 +104,40 @@ install() {
 
        if dracut_module_included "systemd"; then
                mkdir -p "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"
-               for _item in scan cache ; do
-                       dracut_install @systemdunitdir@/zfs-import-$_item.service
-                       if ! [ -L "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"/zfs-import-$_item.service ]; then
-                               ln -s ../zfs-import-$_item.service "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"/zfs-import-$_item.service
-                               type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import-$_item.service
+               for _service in "zfs-import-scan.service" "zfs-import-cache.service" ; do
+                       dracut_install "@systemdunitdir@/$_service"
+                       if ! [ -L "${initdir}/$systemdsystemunitdir/zfs-import.target.wants/$_service" ]; then
+                               ln -sf ../$_service "${initdir}/$systemdsystemunitdir/zfs-import.target.wants/$_service"
+                               type mark_hostonly >/dev/null 2>&1 && mark_hostonly "@systemdunitdir@/$_service"
                        fi
                done
+
                inst "${moddir}"/zfs-env-bootfs.service "${systemdsystemunitdir}"/zfs-env-bootfs.service
                ln -s ../zfs-env-bootfs.service "${initdir}/${systemdsystemunitdir}/zfs-import.target.wants"/zfs-env-bootfs.service
                type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-env-bootfs.service
+
                dracut_install systemd-ask-password
                dracut_install systemd-tty-ask-password-agent
+
                mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants"
                dracut_install @systemdunitdir@/zfs-import.target
                if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import.target ]; then
                        ln -s ../zfs-import.target "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import.target
                        type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import.target
                fi
+
                for _service in zfs-snapshot-bootfs.service zfs-rollback-bootfs.service ; do
-                       inst "${moddir}"/$_service "${systemdsystemunitdir}"/$_service
-                       if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/$_service ]; then
-                               ln -s ../$_service "${initdir}/$systemdsystemunitdir/initrd.target.wants"/$_service
+                       inst "${moddir}/$_service" "${systemdsystemunitdir}/$_service"
+                       if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants/$_service" ]; then
+                               ln -s "../$_service" "${initdir}/$systemdsystemunitdir/initrd.target.wants/$_service"
                        fi
                done
+
+               # There isn't a pkg-config variable for this,
+               # and dracut doesn't automatically resolve anything this'd be next to
+               local systemdsystemenvironmentgeneratordir
+               systemdsystemenvironmentgeneratordir="$(pkg-config --variable=prefix systemd || echo "/usr")/lib/systemd/system-environment-generators"
+               mkdir -p "${initdir}/${systemdsystemenvironmentgeneratordir}"
+               inst "${moddir}"/import-opts-generator.sh "${systemdsystemenvironmentgeneratordir}"/zfs-import-opts.sh
        fi
 }
index 0d236fe9e468d63359ad3ee782b4e69b12369102..b09961a8bb84aca410b8e1721589d3135d06d67a 100644 (file)
@@ -14,7 +14,7 @@ ConditionPathIsDirectory=/sys/module/zfs
 [Service]
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN
+ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN ${ZPOOL_IMPORT_OPTS}
 
 [Install]
 WantedBy=zfs-import.target
index f0317e23e508578b3c4e23d8d0dd098467685380..c1111c73a6071a46c0d44b8e57a03306d04fcbec 100644 (file)
@@ -13,7 +13,7 @@ ConditionPathIsDirectory=/sys/module/zfs
 [Service]
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=@sbindir@/zpool import -aN -o cachefile=none
+ExecStart=@sbindir@/zpool import -aN -o cachefile=none ${ZPOOL_IMPORT_OPTS}
 
 [Install]
 WantedBy=zfs-import.target