mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 10:21:01 +03:00
c75d3968bd
* contrib/initramfs: include /etc/default/zfs and /etc/zfs/zfs-functions At least debian needs /etc/default/zfs and /etc/zfs/zfs-functions for its initramfs. Include both in build when initramfs is configured. * contrib/initramfs: include 60-zvol.rules and zvol_id Include 60-zvol.rules and zvol_id and set udev as predependency instead of debians zdev. This makes debians additional zdev hook unneeded. * Correct initconfdir substitution for some distros Not every Linux distro is using @sysconfdir@/default but @initconfdir@ which is already determined by configure. Let's use it. * systemd: prevent possible conflict between systemd and sysvinit Systemd will not load a sysvinit service if a unit exists with the same name. This prevents conflicts between sysvinit and systemd. In ZFS there is one sysvinit service that does not have a systemd service but a target counterpart, zfs-import.target. Usually it does not make any sense to install both but it is possisble. Let's prevent any conflict by masking zfs-import.service by default. This does not harm even if init.d/zfs-import does not exist. Reviewed-by: Chris Wedgwood <cw@f00f.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Tested-by: Alex Ingram <reimu@reimuhakurei.net> Tested-by: Dreamcat4 <dreamcat4@gmail.com> Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Closes #7904 Closes #9089
109 lines
2.8 KiB
Bash
Executable File
109 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Add ZoL filesystem capabilities to an initrd, usually for a native ZFS root.
|
|
#
|
|
|
|
# This hook installs udev rules for ZoL.
|
|
PREREQ="udev"
|
|
|
|
# These prerequisites are provided by the zfsutils package. The zdb utility is
|
|
# not strictly required, but it can be useful at the initramfs recovery prompt.
|
|
COPY_EXEC_LIST="@sbindir@/zdb @sbindir@/zpool @sbindir@/zfs"
|
|
COPY_EXEC_LIST="$COPY_EXEC_LIST @mounthelperdir@/mount.zfs @udevdir@/vdev_id"
|
|
COPY_EXEC_LIST="$COPY_EXEC_LIST @udevdir@/zvol_id"
|
|
COPY_FILE_LIST="/etc/hostid @sysconfdir@/zfs/zpool.cache"
|
|
COPY_FILE_LIST="$COPY_FILE_LIST @DEFAULT_INITCONF_DIR@/zfs"
|
|
COPY_FILE_LIST="$COPY_FILE_LIST @sysconfdir@/zfs/zfs-functions"
|
|
COPY_FILE_LIST="$COPY_FILE_LIST @sysconfdir@/zfs/vdev_id.conf"
|
|
COPY_FILE_LIST="$COPY_FILE_LIST @udevruledir@/60-zvol.rules"
|
|
COPY_FILE_LIST="$COPY_FILE_LIST @udevruledir@/69-vdev.rules"
|
|
|
|
# These prerequisites are provided by the base system.
|
|
COPY_EXEC_LIST="$COPY_EXEC_LIST /usr/bin/dirname /bin/hostname /sbin/blkid"
|
|
COPY_EXEC_LIST="$COPY_EXEC_LIST /usr/bin/env"
|
|
|
|
# Explicitly specify all kernel modules because automatic dependency resolution
|
|
# is unreliable on many systems.
|
|
BASE_MODULES="zlib_deflate spl zavl zcommon znvpair zunicode zlua zfs icp"
|
|
CRPT_MODULES="sun-ccm sun-gcm sun-ctr"
|
|
MANUAL_ADD_MODULES_LIST="$BASE_MODULES"
|
|
|
|
# Generic result code.
|
|
RC=0
|
|
|
|
case $1 in
|
|
prereqs)
|
|
echo "$PREREQ"
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
for ii in $COPY_EXEC_LIST
|
|
do
|
|
if [ ! -x "$ii" ]
|
|
then
|
|
echo "Error: $ii is not executable."
|
|
RC=2
|
|
fi
|
|
done
|
|
|
|
if [ "$RC" -ne 0 ]
|
|
then
|
|
exit "$RC"
|
|
fi
|
|
|
|
. /usr/share/initramfs-tools/hook-functions
|
|
|
|
mkdir -p "$DESTDIR/etc/"
|
|
|
|
# ZDB uses pthreads for some functions, but the library dependency is not
|
|
# automatically detected. The `find` utility and extended `cp` options are
|
|
# used here because libgcc_s.so could be in a subdirectory of /lib for
|
|
# multi-arch installations.
|
|
cp --target-directory="$DESTDIR" --parents $(find /lib/ -type f -name libgcc_s.so.1)
|
|
|
|
for ii in $COPY_EXEC_LIST
|
|
do
|
|
copy_exec "$ii"
|
|
done
|
|
|
|
for ii in $COPY_FILE_LIST
|
|
do
|
|
dir=$(dirname "$ii")
|
|
[ -d "$dir" ] && mkdir -p "$DESTDIR/$dir"
|
|
[ -f "$ii" ] && cp -p "$ii" "$DESTDIR/$ii"
|
|
done
|
|
|
|
for ii in $MANUAL_ADD_MODULES_LIST
|
|
do
|
|
manual_add_modules "$ii"
|
|
done
|
|
|
|
if [ -f "/etc/hostname" ]
|
|
then
|
|
cp -p "/etc/hostname" "$DESTDIR/etc/"
|
|
else
|
|
hostname >"$DESTDIR/etc/hostname"
|
|
fi
|
|
|
|
for ii in zfs zfs.conf spl spl.conf
|
|
do
|
|
if [ -f "/etc/modprobe.d/$ii" ]; then
|
|
if [ ! -d "$DESTDIR/etc/modprobe.d" ]; then
|
|
mkdir -p $DESTDIR/etc/modprobe.d
|
|
fi
|
|
cp -p "/etc/modprobe.d/$ii" $DESTDIR/etc/modprobe.d/
|
|
fi
|
|
done
|
|
|
|
# With pull request #1476 (not yet merged) comes a verbose warning
|
|
# if /usr/bin/net doesn't exist or isn't executable. Just create
|
|
# a dummy...
|
|
[ ! -d "$DESTDIR/usr/bin" ] && mkdir -p "$DESTDIR/usr/bin"
|
|
if [ ! -x "$DESTDIR/usr/bin/net" ]; then
|
|
touch "$DESTDIR/usr/bin/net"
|
|
chmod +x "$DESTDIR/usr/bin/net"
|
|
fi
|
|
|
|
exit 0
|