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