Skip to content

Commit

Permalink
dracut: 90zfs: respect zfs_force=1 on systemd systems
Browse files Browse the repository at this point in the history
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes openzfs#11403
  • Loading branch information
nabijaczleweli committed May 24, 2021
1 parent 6c7285c commit dfd5ec1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
13 changes: 2 additions & 11 deletions contrib/dracut/90zfs/.gitignore
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion contrib/dracut/90zfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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 \
Expand Down
5 changes: 5 additions & 0 deletions contrib/dracut/90zfs/import-opts-generator.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

. /lib/dracut-zfs-lib.sh

echo ZPOOL_IMPORT_OPTS="$ZPOOL_IMPORT_OPTS"
30 changes: 23 additions & 7 deletions contrib/dracut/90zfs/module-setup.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,44 @@ 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
_service="zfs-import-$_item.service"
dracut_install "@systemdunitdir@/$_service"

mkdir -p "${initdir}/$systemdsystemunitdir/$_service.d"
{
echo "[Service]"
echo "ExecStart="
awk '/^ExecStart=/ {print $0 " $ZPOOL_IMPORT_OPTS"}' "@systemdunitdir@/$_service"
} > "${initdir}/$systemdsystemunitdir/$_service.d/import-opts.conf"

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

mkdir -p "${initdir}/$systemdsystemunitdir/../system-environment-generators"
inst "${moddir}"/import-opts-generator.sh "${systemdsystemunitdir}/../system-environment-generators"/zfs-import-opts.sh
fi
}

0 comments on commit dfd5ec1

Please sign in to comment.