1#!/bin/sh 2# 3# Add OpenZFS filesystem capabilities to an initrd, usually for a native ZFS root. 4# 5 6if [ "$1" = "prereqs" ]; then 7 echo "udev" 8 exit 9fi 10 11. /usr/share/initramfs-tools/hook-functions 12 13for req in "@sbindir@/zpool" "@sbindir@/zfs" "@mounthelperdir@/mount.zfs"; do 14 copy_exec "$req" || { 15 echo "$req not available!" >&2 16 exit 2 17 } 18done 19 20copy_exec "@sbindir@/zdb" 21copy_exec "@udevdir@/vdev_id" 22copy_exec "@udevdir@/zvol_id" 23if command -v systemd-ask-password > /dev/null; then 24 copy_exec "$(command -v systemd-ask-password)" 25fi 26 27# We use pthreads, but i-t from buster doesn't automatically 28# copy this indirect dependency: this can be removed when buster finally dies. 29find /lib/ -type f -name "libgcc_s.so.[1-9]" | while read -r libgcc; do 30 copy_exec "$libgcc" 31done 32 33# shellcheck disable=SC2050 34if [ @LIBFETCH_DYNAMIC@ != 0 ]; then 35 find /lib/ -name @LIBFETCH_SONAME@ | while read -r libfetch; do 36 copy_exec "$libfetch" 37 done 38fi 39 40copy_file config "/etc/hostid" 41copy_file cache "@sysconfdir@/zfs/zpool.cache" 42copy_file config "@initconfdir@/zfs" 43copy_file config "@sysconfdir@/zfs/zfs-functions" 44copy_file config "@sysconfdir@/zfs/vdev_id.conf" 45copy_file rule "@udevruledir@/60-zvol.rules" 46copy_file rule "@udevruledir@/69-vdev.rules" 47 48manual_add_modules zfs 49 50if [ -f "/etc/hostname" ]; then 51 copy_file config "/etc/hostname" 52else 53 hostname="$(mktemp -t hostname.XXXXXXXXXX)" 54 hostname > "$hostname" 55 copy_file config "$hostname" "/etc/hostname" 56 rm -f "$hostname" 57fi 58