]> git.proxmox.com Git - mirror_zfs.git/blame - contrib/initramfs/hooks/zfs.in
i-t: rewrite hooks
[mirror_zfs.git] / contrib / initramfs / hooks / zfs.in
CommitLineData
2cac7f5f
TF
1#!/bin/sh
2#
1966e959 3# Add OpenZFS filesystem capabilities to an initrd, usually for a native ZFS root.
2cac7f5f
TF
4#
5
5236eafd
AZ
6if [ "$1" = "prereqs" ]; then
7 echo "udev"
8 exit
9fi
2cac7f5f 10
5236eafd 11. /usr/share/initramfs-tools/hook-functions
2cac7f5f 12
5236eafd
AZ
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 }
2cac7f5f
TF
18done
19
5236eafd
AZ
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)"
2cac7f5f
TF
25fi
26
5236eafd
AZ
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.
29for libgcc in $(find /lib/ -type f -name libgcc_s.so.[1-9]); do
30 copy_exec "$libgcc"
31done
2cac7f5f 32
5236eafd
AZ
33if [ @LIBFETCH_DYNAMIC@ != 0 ]; then
34 for libfetch in $(find /lib/ -name @LIBFETCH_SONAME@); do
35 copy_exec "$libfetch"
37086897
AZ
36 done
37fi
38
5236eafd
AZ
39copy_file config "/etc/hostid"
40copy_file cache "@sysconfdir@/zfs/zpool.cache"
41copy_file config "@initconfdir@/zfs"
42copy_file config "@sysconfdir@/zfs/zfs-functions"
43copy_file config "@sysconfdir@/zfs/vdev_id.conf"
44copy_file rule "@udevruledir@/60-zvol.rules"
45copy_file rule "@udevruledir@/69-vdev.rules"
2cac7f5f 46
5236eafd 47manual_add_modules zfs
2cac7f5f 48
5236eafd
AZ
49if [ -f "/etc/hostname" ]; then
50 copy_file config "/etc/hostname"
2cac7f5f 51else
5236eafd
AZ
52 hostname="$(mktemp -t hostname.XXXXXXXXXX)"
53 hostname > "$hostname"
54 copy_file config "$hostname" "/etc/hostname"
55 rm -f "$hostname"
2cac7f5f 56fi