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 zfsonlinux/zfs#4749 by ensuring libgcc_s.so(.1) is included
45 if [[ -n "$(ldd @sbindir@/zpool | grep -F 'libgcc_s.so')" ]]; then
46 # Dracut will have already tracked and included it
48 elif command -v gcc-config 2>&1 1>/dev/null; then
49 # On systems with gcc-config (Gentoo, Funtoo, etc.):
50 # Use the current profile to resolve the appropriate path
51 dracut_install "/usr/lib/gcc/$(s=$(gcc-config -c); echo ${s%-*}/${s##*-})/libgcc_s.so.1"
52 elif [[ -n "$(ls /usr/lib/libgcc_s.so* 2>/dev/null)" ]]; then
53 # Try a simple path first
54 dracut_install /usr/lib/libgcc_s.so*
56 # Fallback: Guess the path and include all matches
57 dracut_install /usr/lib/gcc/*/*/libgcc_s.so*
59 dracut_install @mounthelperdir@/mount.zfs
60 dracut_install @udevdir@/vdev_id
62 dracut_install basename
65 dracut_install @udevdir@/zvol_id
66 inst_hook cmdline 95 "${moddir}/parse-zfs.sh"
67 if [ -n "$systemdutildir" ] ; then
68 inst_script "${moddir}/zfs-generator.sh" "$systemdutildir"/system-generators/dracut-zfs-generator
70 inst_hook pre-mount 90 "${moddir}/zfs-load-key.sh"
71 inst_hook mount 98 "${moddir}/mount-zfs.sh"
72 inst_hook cleanup 99 "${moddir}/zfs-needshutdown.sh"
73 inst_hook shutdown 20 "${moddir}/export-zfs.sh"
75 inst_simple "${moddir}/zfs-lib.sh" "/lib/dracut-zfs-lib.sh"
76 if [ -e @sysconfdir@/zfs/zpool.cache ]; then
77 inst @sysconfdir@/zfs/zpool.cache
78 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/zpool.cache
81 if [ -e @sysconfdir@/zfs/vdev_id.conf ]; then
82 inst @sysconfdir@/zfs/vdev_id.conf
83 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/vdev_id.conf
86 # Synchronize initramfs and system hostid
87 zgenhostid -o "${initdir}/etc/hostid" "$(hostid)"
89 if dracut_module_included "systemd"; then
90 mkdir -p "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"
91 for _item in scan cache ; do
92 dracut_install @systemdunitdir@/zfs-import-$_item.service
93 if ! [ -L "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"/zfs-import-$_item.service ]; then
94 ln -s ../zfs-import-$_item.service "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"/zfs-import-$_item.service
95 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import-$_item.service
98 inst "${moddir}"/zfs-env-bootfs.service "${systemdsystemunitdir}"/zfs-env-bootfs.service
99 ln -s ../zfs-env-bootfs.service "${initdir}/${systemdsystemunitdir}/zfs-import.target.wants"/zfs-env-bootfs.service
100 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-env-bootfs.service
101 dracut_install systemd-ask-password
102 dracut_install systemd-tty-ask-password-agent
103 mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants"
104 dracut_install @systemdunitdir@/zfs-import.target
105 if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import.target ]; then
106 ln -s ../zfs-import.target "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import.target
107 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import.target
109 for _service in zfs-snapshot-bootfs.service zfs-rollback-bootfs.service ; do
110 inst "${moddir}"/$_service "${systemdsystemunitdir}"/$_service
111 if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/$_service ]; then
112 ln -s ../$_service "${initdir}/$systemdsystemunitdir/initrd.target.wants"/$_service