]> git.proxmox.com Git - mirror_zfs.git/blame - contrib/dracut/90zfs/module-setup.sh.in
Adapt genkernel fix for zfsonlinux/zfs#4749 to zfs dracut module
[mirror_zfs.git] / contrib / dracut / 90zfs / module-setup.sh.in
CommitLineData
fde4ce99
ZB
1#!/bin/sh
2
3check() {
1ef5e829 4 # We depend on udev-rules being loaded
eda3d4e1 5 [ "${1}" = "-d" ] && return 0
fde4ce99 6
1ef5e829 7 # Verify the zfs tool chain
d402c18d
MAR
8 for tool in "@sbindir@/zpool" "@sbindir@/zfs" "@sbindir@/mount.zfs" ; do
9 test -x "$tool" || return 1
10 done
11 # Verify grep exists
12 which grep >/dev/null 2>&1 || return 1
fde4ce99 13
1ef5e829 14 return 0
fde4ce99
ZB
15}
16
17depends() {
1ef5e829
ZB
18 echo udev-rules
19 return 0
fde4ce99
ZB
20}
21
22installkernel() {
1ef5e829
ZB
23 instmods zfs
24 instmods zcommon
25 instmods znvpair
26 instmods zavl
27 instmods zunicode
28 instmods spl
29 instmods zlib_deflate
30 instmods zlib_inflate
fde4ce99
ZB
31}
32
33install() {
f0102d6e 34 inst_rules @udevruledir@/90-zfs.rules
b9676003 35 inst_rules @udevruledir@/69-vdev.rules
f0102d6e 36 inst_rules @udevruledir@/60-zvol.rules
d402c18d
MAR
37 dracut_install hostid
38 dracut_install grep
f0102d6e
KF
39 dracut_install @sbindir@/zfs
40 dracut_install @sbindir@/zpool
61c73494
MM
41 # Include libgcc_s.so.1 to workaround zfsonlinux/zfs#4749
42 if type gcc-config 2>&1 1>/dev/null; then
43 dracut_install "/usr/lib/gcc/$(s=$(gcc-config -c); echo ${s%-*}/${s##*-})/libgcc_s.so.1"
44 else
45 dracut_install /usr/lib/gcc/*/*/libgcc_s.so.1
46 fi
d402c18d 47 dracut_install @sbindir@/mount.zfs
dbf763b3 48 dracut_install @udevdir@/vdev_id
f0102d6e 49 dracut_install @udevdir@/zvol_id
eda3d4e1 50 inst_hook cmdline 95 "${moddir}/parse-zfs.sh"
a5a37022
MT
51 if [ -n "$systemdutildir" ] ; then
52 inst_script "${moddir}/zfs-generator.sh" "$systemdutildir"/system-generators/dracut-zfs-generator
a5a37022 53 fi
d402c18d 54 inst_hook mount 98 "${moddir}/mount-zfs.sh"
eda3d4e1 55 inst_hook shutdown 30 "${moddir}/export-zfs.sh"
e8753fb4 56
eda3d4e1 57 inst_simple "${moddir}/zfs-lib.sh" "/lib/dracut-zfs-lib.sh"
b9676003
BB
58 if [ -e @sysconfdir@/zfs/zpool.cache ]; then
59 inst @sysconfdir@/zfs/zpool.cache
a5a37022 60 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/zpool.cache
b9676003
BB
61 fi
62
1543b20a
SM
63 if [ -e @sysconfdir@/zfs/vdev_id.conf ]; then
64 inst @sysconfdir@/zfs/vdev_id.conf
a5a37022 65 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/vdev_id.conf
1543b20a
SM
66 fi
67
e8753fb4 68 # Synchronize initramfs and system hostid
e8753fb4
BB
69 AA=`hostid | cut -b 1,2`
70 BB=`hostid | cut -b 3,4`
71 CC=`hostid | cut -b 5,6`
72 DD=`hostid | cut -b 7,8`
eda3d4e1 73 printf "\x${DD}\x${CC}\x${BB}\x${AA}" > "${initdir}/etc/hostid"
a5a37022
MT
74
75 if dracut_module_included "systemd"; then
76 mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants"
77 for _item in scan cache ; do
78 dracut_install @systemdunitdir@/zfs-import-$_item.service
79 if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import-$_item.service ]; then
80 ln -s ../zfs-import-$_item.service "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import-$_item.service
81 type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import-$_item.service
82 fi
83 done
84 fi
fde4ce99 85}