--- /dev/null
+module-setup.sh
local poolconfigoutput
local pooldev
local prefix
+ local resolved
poolconfigtemp=`mktemp`
- @sbindir@/zpool list -v -H "$1" > "$poolconfigtemp" 2>&1
+ @sbindir@/zpool list -v -H -P "$1" > "$poolconfigtemp" 2>&1
if [ "$?" != "0" ] ; then
poolconfigoutput=$(cat "$poolconfigtemp")
dinfo "zfsexpandknowledge: pool $1 cannot be listed: $poolconfigoutput"
else
while read pooldev ; do
- for prefix in /dev/disk/* /dev/mapper ; do
- if [ -e "$prefix"/"$pooldev" ] ; then
- dinfo "zfsexpandknowledge: pool $1 has device $prefix/$pooldev"
- echo `readlink -f "$prefix"/"$pooldev"`
- break
+ if [ -n "$pooldev" -a -e "$pooldev" ] ; then
+ if [ -h "$pooldev" ] ; then
+ resolved=`readlink -f "$pooldev"`
+ else
+ resolved="$pooldev"
+ fi
+ dinfo "zfsexpandknowledge: pool $1 has device $pooldev (which resolves to $resolved)"
+ echo "$resolved"
fi
- done
- done < <(cat "$poolconfigtemp" | awk -F '\t' 'NR>1 { print $2 }')
+ done < <(cat "$poolconfigtemp" | awk -F '\t' '/\t\/dev/ { print $2 }')
fi
rm -f "$poolconfigtemp"
}
module-setup.sh
mount-zfs.sh
parse-zfs.sh
+zfs-generator.sh
zfs-lib.sh
[ "${1}" = "-d" ] && return 0
# Verify the zfs tool chain
- which zpool >/dev/null 2>&1 || return 1
- which zfs >/dev/null 2>&1 || return 1
+ for tool in "@sbindir@/zpool" "@sbindir@/zfs" "@sbindir@/mount.zfs" ; do
+ test -x "$tool" || return 1
+ done
+ # Verify grep exists
+ which grep >/dev/null 2>&1 || return 1
return 0
}
inst_rules @udevruledir@/90-zfs.rules
inst_rules @udevruledir@/69-vdev.rules
inst_rules @udevruledir@/60-zvol.rules
+ dracut_install hostid
+ dracut_install grep
dracut_install @sbindir@/zfs
dracut_install @sbindir@/zpool
+ dracut_install @sbindir@/mount.zfs
dracut_install @udevdir@/vdev_id
dracut_install @udevdir@/zvol_id
- dracut_install mount.zfs
- dracut_install hostid
- dracut_install awk
- dracut_install head
inst_hook cmdline 95 "${moddir}/parse-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 mount 98 "${moddir}/mount-zfs.sh"
inst_hook shutdown 30 "${moddir}/export-zfs.sh"
inst_simple "${moddir}/zfs-lib.sh" "/lib/dracut-zfs-lib.sh"
*) return ;;
esac
+# If sysroot.mount exists, the initial RAM disk configured
+# it to mount ZFS on root. In that case, we bail early.
+loadstate="$(systemctl --system --show -p LoadState sysroot.mount || true)"
+if [ "${loadstate}" = "LoadState=not-found" -o "${loadstate}" = "" ] ; then
+ info "ZFS: sysroot.mount absent, mounting root with mount-zfs.sh"
+else
+ info "ZFS: sysroot.mount present, delegating root mount to it"
+ return
+fi
+
# Delay until all required block devices are present.
udevadm settle
# modules to settle before mounting.
if [ ${wait_for_zfs} -eq 1 ]; then
ln -s /dev/null /dev/root 2>/dev/null
- echo '[ -e /dev/zfs ]' > "${hookdir}/initqueue/finished/zfs.sh"
+ initqueuedir="${hookdir}/initqueue/finished"
+ test -d initqueuedir || {
+ initqueuedir="${hookdir}/initqueue-finished"
+ }
+ echo '[ -e /dev/zfs ]' > "${initqueuedir}/zfs.sh"
fi
[ -z "$rootflags" ] && rootflags=$(getarg rootflags=)
[ "${root##zfs:}" = "${root}" -a "${root##ZFS=}" = "${root}" -a "$rootfstype" != "zfs" ] && exit 0
+# If root is set to zfs:AUTO, then we know sysroot.mount will not be generated
+# so we have no need to enhance it.
+# See https://github.com/zfsonlinux/zfs/pull/4558#discussion_r61118952 for details.
+if [ "${root}" = "zfs:AUTO" ] ; then
+ exit 0
+fi
rootfstype=zfs
-if echo "${rootflags}" | grep -q zfsutil ; then
+if echo "${rootflags}" | grep -Eq '^zfsutil$|^zfsutil,|,zfsutil$|,zfsutil,' ; then
true
+elif test -n "${rootflags}" ; then
+ rootflags="zfsutil,${rootflags}"
else
rootflags=zfsutil
fi
#!/bin/sh
command -v getarg >/dev/null || . /lib/dracut-lib.sh
+command -v getargbool >/dev/null || {
+ # Compatibility with older Dracut versions.
+ # With apologies to the Dracut developers.
+ getargbool() {
+ local _b
+ unset _b
+ local _default
+ _default="$1"; shift
+ _b=$(getarg "$@")
+ [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
+ if [ -n "$_b" ]; then
+ [ $_b = "0" ] && return 1
+ [ $_b = "no" ] && return 1
+ [ $_b = "off" ] && return 1
+ fi
+ return 0
+ }
+}
OLDIFS="${IFS}"
NEWLINE="
Requires=systemd-udev-settle.service
After=systemd-udev-settle.service
After=cryptsetup.target
+Before=dracut-mount.service
ConditionPathExists=@sysconfdir@/zfs/zpool.cache
[Service]
Requires=systemd-udev-settle.service
After=systemd-udev-settle.service
After=cryptsetup.target
+Before=dracut-mount.service
ConditionPathExists=!@sysconfdir@/zfs/zpool.cache
[Service]