4 # We depend on udev-rules being loaded
5 [ "${1}" = "-d" ] && return 0
7 # Verify the zfs tool chain
8 for tool in "@bindir@/zgenhostid" "@sbindir@/zpool" "@sbindir@/zfs" "@mounthelperdir@/mount.zfs" ; do
9 test -x "$tool" || return 1
12 which grep >/dev/null 2>&1 || return 1
36 inst_rules @udevruledir@/90-zfs.rules
37 inst_rules @udevruledir@/69-vdev.rules
38 inst_rules @udevruledir@/60-zvol.rules
41 dracut_install @bindir@/zgenhostid
42 dracut_install @sbindir@/zfs
43 dracut_install @sbindir@/zpool
44 # Workaround for https://github.com/openzfs/zfs/issues/4749 by
45 # ensuring libgcc_s.so(.1) is included
46 if [[ -n "$(ldd @sbindir@/zpool | grep -F 'libgcc_s.so')" ]]; then
47 # Dracut will have already tracked and included it
49 elif command -v gcc-config 2>&1 1>/dev/null; then
50 # On systems with gcc-config (Gentoo, Funtoo, etc.):
51 # Use the current profile to resolve the appropriate path
52 dracut_install "/usr/lib/gcc/$(s=$(gcc-config -c); echo ${s%-*}/${s##*-})/libgcc_s.so.1"
53 elif [[ -n "$(ls /usr/lib/libgcc_s.so* 2>/dev/null)" ]]; then
54 # Try a simple path first
55 dracut_install /usr/lib/libgcc_s.so*
57 # Fallback: Guess the path and include all matches
58 dracut_install /usr/lib/gcc/*/*/libgcc_s.so*
60 dracut_install @mounthelperdir@/mount.zfs
61 dracut_install @udevdir@/vdev_id
63 dracut_install basename
66 dracut_install @udevdir@/zvol_id
67 inst_hook cmdline 95 "${moddir}/parse-zfs.sh"
68 if [ -n "$systemdutildir" ] ; then
69 inst_script "${moddir}/zfs-generator.sh" "$systemdutildir"/system-generators/dracut-zfs-generator
71 inst_hook pre-mount 90 "${moddir}/zfs-load-key.sh"
72 inst_hook mount 98 "${moddir}/mount-zfs.sh"
73 inst_hook cleanup 99 "${moddir}/zfs-needshutdown.sh"
74 inst_hook shutdown 20 "${moddir}/export-zfs.sh"
76 inst_simple "${moddir}/zfs-lib.sh" "/lib/dracut-zfs-lib.sh"
77 if [ -e @sysconfdir@/zfs/zpool.cache ]; then
78 inst @sysconfdir@/zfs/zpool.cache
79 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/zpool.cache
82 if [ -e @sysconfdir@/zfs/vdev_id.conf ]; then
83 inst @sysconfdir@/zfs/vdev_id.conf
84 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/vdev_id.conf
87 # Synchronize initramfs and system hostid
88 zgenhostid -o "${initdir}/etc/hostid" "$(hostid)"
90 if dracut_module_included "systemd"; then
91 mkdir -p "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"
92 for _item in scan cache ; do
93 dracut_install @systemdunitdir@/zfs-import-$_item.service
94 if ! [ -L "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"/zfs-import-$_item.service ]; then
95 ln -s ../zfs-import-$_item.service "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"/zfs-import-$_item.service
96 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import-$_item.service
99 inst "${moddir}"/zfs-env-bootfs.service "${systemdsystemunitdir}"/zfs-env-bootfs.service
100 ln -s ../zfs-env-bootfs.service "${initdir}/${systemdsystemunitdir}/zfs-import.target.wants"/zfs-env-bootfs.service
101 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-env-bootfs.service
102 dracut_install systemd-ask-password
103 dracut_install systemd-tty-ask-password-agent
104 mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants"
105 dracut_install @systemdunitdir@/zfs-import.target
106 if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import.target ]; then
107 ln -s ../zfs-import.target "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import.target
108 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import.target
110 for _service in zfs-snapshot-bootfs.service zfs-rollback-bootfs.service ; do
111 inst "${moddir}"/$_service "${systemdsystemunitdir}"/$_service
112 if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/$_service ]; then
113 ln -s ../$_service "${initdir}/$systemdsystemunitdir/initrd.target.wants"/$_service