diff options
author | Matthew Thode <[email protected]> | 2016-03-30 18:59:15 -0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-04-25 08:51:38 -0700 |
commit | a5a370227eb0a3daf8992a38920d54eb3b7b3c25 (patch) | |
tree | cc85181222f7cd64ff79c9eae7013588730977c2 /contrib/dracut/90zfs | |
parent | 232604b58e8579501c5a260ad3a7b71a239dd546 (diff) |
fix booting via dracut generated initramfs
Dracut and Systemd updated how they integrate with each other, because
of this our current integrations stopped working (around the time
4.1.13 came out). This patch addresses that issue and gets us booting
again.
Thanks to @Rudd-O for doing the work to get dracut working again and
letting me submit this on his behalf.
Signed-off-by: Manuel Amador (Rudd-O) <[email protected]>
Signed-off-by: Matthew Thode <[email protected]>
Closes #3605
Closes #4478
Diffstat (limited to 'contrib/dracut/90zfs')
-rw-r--r-- | contrib/dracut/90zfs/Makefile.am | 3 | ||||
-rwxr-xr-x | contrib/dracut/90zfs/module-setup.sh.in | 19 | ||||
-rw-r--r-- | contrib/dracut/90zfs/zfs-generator.sh.in | 39 |
3 files changed, 60 insertions, 1 deletions
diff --git a/contrib/dracut/90zfs/Makefile.am b/contrib/dracut/90zfs/Makefile.am index b778a2744..f81d6c357 100644 --- a/contrib/dracut/90zfs/Makefile.am +++ b/contrib/dracut/90zfs/Makefile.am @@ -4,6 +4,7 @@ pkgdracut_SCRIPTS = \ module-setup.sh \ mount-zfs.sh \ parse-zfs.sh \ + zfs-generator.sh \ zfs-lib.sh EXTRA_DIST = \ @@ -11,6 +12,7 @@ EXTRA_DIST = \ $(top_srcdir)/contrib/dracut/90zfs/module-setup.sh.in \ $(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-lib.sh.in $(pkgdracut_SCRIPTS): @@ -19,6 +21,7 @@ $(pkgdracut_SCRIPTS): -e 's,@udevdir\@,$(udevdir),g' \ -e 's,@udevruledir\@,$(udevruledir),g' \ -e 's,@sysconfdir\@,$(sysconfdir),g' \ + -e 's,@systemdunitdir\@,$(systemdunitdir),g' \ "$(top_srcdir)/contrib/dracut/90zfs/[email protected]" >'$@' distclean-local:: diff --git a/contrib/dracut/90zfs/module-setup.sh.in b/contrib/dracut/90zfs/module-setup.sh.in index 9eb9f5765..301375a5b 100755 --- a/contrib/dracut/90zfs/module-setup.sh.in +++ b/contrib/dracut/90zfs/module-setup.sh.in @@ -40,16 +40,22 @@ install() { dracut_install awk dracut_install head inst_hook cmdline 95 "${moddir}/parse-zfs.sh" - inst_hook mount 98 "${moddir}/mount-zfs.sh" + if [ -n "$systemdutildir" ] ; then + inst_script "${moddir}/zfs-generator.sh" "$systemdutildir"/system-generators/dracut-zfs-generator + else + inst_hook mount 98 "${moddir}/mount-zfs.sh" + fi inst_hook shutdown 30 "${moddir}/export-zfs.sh" inst_simple "${moddir}/zfs-lib.sh" "/lib/dracut-zfs-lib.sh" if [ -e @sysconfdir@/zfs/zpool.cache ]; then inst @sysconfdir@/zfs/zpool.cache + type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/zpool.cache fi if [ -e @sysconfdir@/zfs/vdev_id.conf ]; then inst @sysconfdir@/zfs/vdev_id.conf + type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/vdev_id.conf fi # Synchronize initramfs and system hostid @@ -58,4 +64,15 @@ install() { CC=`hostid | cut -b 5,6` DD=`hostid | cut -b 7,8` printf "\x${DD}\x${CC}\x${BB}\x${AA}" > "${initdir}/etc/hostid" + + if dracut_module_included "systemd"; then + mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants" + for _item in scan cache ; do + dracut_install @systemdunitdir@/zfs-import-$_item.service + if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import-$_item.service ]; then + ln -s ../zfs-import-$_item.service "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import-$_item.service + type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import-$_item.service + fi + done + fi } diff --git a/contrib/dracut/90zfs/zfs-generator.sh.in b/contrib/dracut/90zfs/zfs-generator.sh.in new file mode 100644 index 000000000..0e0664d0a --- /dev/null +++ b/contrib/dracut/90zfs/zfs-generator.sh.in @@ -0,0 +1,39 @@ +#!/bin/bash + +GENERATOR_DIR="$1" +[ -z "$GENERATOR_DIR" ] && exit 1 + +[ -f /lib/dracut-lib.sh ] && dracutlib=/lib/dracut-lib.sh +[ -f /usr/lib/dracut/modules.d/99base/dracut-lib.sh ] && dracutlib=/usr/lib/dracut/modules.d/99base/dracut-lib.sh + +type getarg >/dev/null 2>&1 || . "$dracutlib" + +[ -z "$root" ] && root=$(getarg root=) +[ -z "$rootfstype" ] && rootfstype=$(getarg rootfstype=) +[ -z "$rootflags" ] && rootflags=$(getarg rootflags=) + +[ "${root##zfs:}" = "${root}" -a "${root##ZFS=}" = "${root}" -a "$rootfstype" != "zfs" ] && exit 0 + +rootfstype=zfs +if echo "${rootflags}" | grep -q zfsutil ; then + true +else + rootflags=zfsutil +fi + +root="${root##zfs:}" +root="${root##ZFS=}" + +[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR" +[ -d "$GENERATOR_DIR/sysroot.mount.d" ] || mkdir "$GENERATOR_DIR/sysroot.mount.d" + +{ + echo "[Unit]" + echo "After=zfs-import-scan.service" + echo "After=zfs-import-cache.service" + echo "" + echo "[Mount]" + echo "What=${root}" + echo "Type=${rootfstype}" + echo "Options=${rootflags}" +} > "$GENERATOR_DIR/sysroot.mount.d/zfs-enhancement.conf" |