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
="@sbindir@/zdb @sbindir@/zpool @sbindir@/zfs"
12 COPY_EXEC_LIST
="$COPY_EXEC_LIST @mounthelperdir@/mount.zfs @udevdir@/vdev_id"
13 COPY_FILE_LIST
="/etc/hostid @sysconfdir@/zfs/zpool.cache"
14 COPY_FILE_LIST
="$COPY_FILE_LIST @sysconfdir@/default/zfs"
15 COPY_FILE_LIST
="$COPY_FILE_LIST @sysconfdir@/zfs/zfs-functions"
16 COPY_FILE_LIST
="$COPY_FILE_LIST @sysconfdir@/zfs/vdev_id.conf"
17 COPY_FILE_LIST
="$COPY_FILE_LIST @udevruledir@/69-vdev.rules"
19 # These prerequisites are provided by the base system.
20 COPY_EXEC_LIST
="$COPY_EXEC_LIST /usr/bin/dirname /bin/hostname /sbin/blkid"
21 COPY_EXEC_LIST
="$COPY_EXEC_LIST /usr/bin/env"
23 # Explicitly specify all kernel modules because automatic dependency resolution
24 # is unreliable on many systems.
25 BASE_MODULES
="zlib_deflate spl zavl zcommon znvpair zunicode zlua zfs icp"
26 CRPT_MODULES
="sun-ccm sun-gcm sun-ctr"
27 MANUAL_ADD_MODULES_LIST
="$BASE_MODULES"
29 # Generic result code.
39 for ii
in $COPY_EXEC_LIST
43 echo "Error: $ii is not executable."
53 .
/usr
/share
/initramfs-tools
/hook-functions
55 mkdir
-p "$DESTDIR/etc/"
57 # ZDB uses pthreads for some functions, but the library dependency is not
58 # automatically detected. The `find` utility and extended `cp` options are
59 # used here because libgcc_s.so could be in a subdirectory of /lib for
60 # multi-arch installations.
61 cp --target-directory="$DESTDIR" --parents $
(find /lib
/ -type f
-name libgcc_s.so
.1)
63 for ii
in $COPY_EXEC_LIST
68 for ii
in $COPY_FILE_LIST
71 [ -d "$dir" ] && mkdir
-p "$DESTDIR/$dir"
72 [ -f "$ii" ] && cp -p "$ii" "$DESTDIR/$ii"
75 for ii
in $MANUAL_ADD_MODULES_LIST
77 manual_add_modules
"$ii"
80 if [ -f "/etc/hostname" ]
82 cp -p "/etc/hostname" "$DESTDIR/etc/"
84 hostname
>"$DESTDIR/etc/hostname"
87 for ii
in zfs zfs.conf spl spl.conf
89 if [ -f "/etc/modprobe.d/$ii" ]; then
90 if [ ! -d "$DESTDIR/etc/modprobe.d" ]; then
91 mkdir
-p $DESTDIR/etc
/modprobe.d
93 cp -p "/etc/modprobe.d/$ii" $DESTDIR/etc
/modprobe.d
/
97 # With pull request #1476 (not yet merged) comes a verbose warning
98 # if /usr/bin/net doesn't exist or isn't executable. Just create
100 [ ! -d "$DESTDIR/usr/bin" ] && mkdir
-p "$DESTDIR/usr/bin"
101 if [ ! -x "$DESTDIR/usr/bin/net" ]; then
102 touch "$DESTDIR/usr/bin/net"
103 chmod +x
"$DESTDIR/usr/bin/net"