3 # Add ZoL filesystem capabilities to an initrd, usually for a native ZFS root.
6 # This hook installs udev rules for ZoL.
9 # These prerequisites are provided by the zfsutils package. The zdb utility is
10 # not strictly required, but it can be useful at the initramfs recovery prompt.
11 COPY_EXEC_LIST
="/sbin/zdb /sbin/zpool /sbin/zfs /sbin/mount.zfs"
12 COPY_EXEC_LIST
="$COPY_EXEC_LIST /usr/bin/dirname /lib/udev/vdev_id"
13 COPY_FILE_LIST
="/etc/hostid /etc/zfs/zpool.cache /etc/default/zfs"
14 COPY_FILE_LIST
="$COPY_FILE_LIST /etc/zfs/zfs-functions /etc/zfs/vdev_id.conf"
15 COPY_FILE_LIST
="$COPY_FILE_LIST /lib/udev/rules.d/69-vdev.rules"
17 # These prerequisites are provided by the base system.
18 COPY_EXEC_LIST
="$COPY_EXEC_LIST /bin/hostname /sbin/blkid"
20 # Explicitly specify all kernel modules because automatic dependency resolution
21 # is unreliable on many systems.
22 BASE_MODULES
="zlib_deflate spl zavl zcommon znvpair zunicode zfs icp"
23 CRPT_MODULES
="sun-ccm sun-gcm sun-ctr"
24 MANUAL_ADD_MODULES_LIST
="$BASE_MODULES"
26 # Generic result code.
36 for ii
in $COPY_EXEC_LIST
40 echo "Error: $ii is not executable."
50 .
/usr
/share
/initramfs-tools
/hook-functions
52 mkdir
-p "$DESTDIR/etc/"
54 # ZDB uses pthreads for some functions, but the library dependency is not
55 # automatically detected. The `find` utility and extended `cp` options are
56 # used here because libgcc_s.so could be in a subdirectory of /lib for
57 # multi-arch installations.
58 cp --target-directory="$DESTDIR" --parents $
(find /lib
/ -type f
-name libgcc_s.so
.1)
60 for ii
in $COPY_EXEC_LIST
65 for ii
in $COPY_FILE_LIST
68 [ -d "$dir" ] && mkdir
-p "$DESTDIR/$dir"
69 [ -f "$ii" ] && cp -p "$ii" "$DESTDIR/$ii"
72 for ii
in $MANUAL_ADD_MODULES_LIST
74 manual_add_modules
"$ii"
77 if [ -f "/etc/hostname" ]
79 cp -p "/etc/hostname" "$DESTDIR/etc/"
81 hostname
>"$DESTDIR/etc/hostname"
84 for ii
in zfs zfs.conf spl spl.conf
86 if [ -f "/etc/modprobe.d/$ii" ]; then
87 if [ ! -d "$DESTDIR/etc/modprobe.d" ]; then
88 mkdir
-p $DESTDIR/etc
/modprobe.d
90 cp -p "/etc/modprobe.d/$ii" $DESTDIR/etc
/modprobe.d
/
94 # With pull request #1476 (not yet merged) comes a verbose warning
95 # if /usr/bin/net doesn't exist or isn't executable. Just create
97 [ ! -d "$DESTDIR/usr/bin" ] && mkdir
-p "$DESTDIR/usr/bin"
98 if [ ! -x "$DESTDIR/usr/bin/net" ]; then
99 touch "$DESTDIR/usr/bin/net"
100 chmod +x
"$DESTDIR/usr/bin/net"