aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorнаб <nabijaczleweli@nabijaczleweli.xyz>2021-06-10 18:26:37 +0200
committerBrian Behlendorf <behlendorf1@llnl.gov>2021-06-10 10:50:16 -0700
commit8dc540ae1601e4075da64ded1cb75406c4969f87 (patch)
tree901fce287e804696d2919201dde6107054fa5357 /contrib
parentefdfb14fc8c9b847c4758ea12842d82e79c40d5d (diff)
dracut: 90zfs: respect zfs_force=1 on systemd systems
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
Diffstat (limited to 'contrib')
-rw-r--r--contrib/dracut/90zfs/.gitignore13
-rw-r--r--contrib/dracut/90zfs/Makefile.am3
-rwxr-xr-xcontrib/dracut/90zfs/import-opts-generator.sh.in5
-rwxr-xr-xcontrib/dracut/90zfs/module-setup.sh.in27
4 files changed, 28 insertions, 20 deletions
diff --git a/contrib/dracut/90zfs/.gitignore b/contrib/dracut/90zfs/.gitignore
index dce243934..cb84212f3 100644
--- a/contrib/dracut/90zfs/.gitignore
+++ b/contrib/dracut/90zfs/.gitignore
@@ -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
diff --git a/contrib/dracut/90zfs/Makefile.am b/contrib/dracut/90zfs/Makefile.am
index ff3a2b27f..3f7050300 100644
--- a/contrib/dracut/90zfs/Makefile.am
+++ b/contrib/dracut/90zfs/Makefile.am
@@ -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
index 000000000..8bc8c9b35
--- /dev/null
+++ b/contrib/dracut/90zfs/import-opts-generator.sh.in
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+. /lib/dracut-zfs-lib.sh
+
+echo ZPOOL_IMPORT_OPTS="$ZPOOL_IMPORT_OPTS"
diff --git a/contrib/dracut/90zfs/module-setup.sh.in b/contrib/dracut/90zfs/module-setup.sh.in
index 1e97e674d..213b48a25 100755
--- a/contrib/dracut/90zfs/module-setup.sh.in
+++ b/contrib/dracut/90zfs/module-setup.sh.in
@@ -98,29 +98,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
}