Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] 'Fixes' for initramfs creation #8796

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions contrib/initramfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@ initrddir = $(datarootdir)/initramfs-tools
initrd_SCRIPTS = \
conf.d/zfs conf-hooks.d/zfs hooks/zfs scripts/zfs scripts/local-top/zfs

SUBDIRS = hooks scripts
SUBDIRS = hooks scripts ../../etc

EXTRA_DIST = \
$(top_srcdir)/etc/init.d/zfs \
$(top_srcdir)/etc/init.d/zfs-functions \
$(top_srcdir)/contrib/initramfs/conf.d/zfs \
$(top_srcdir)/contrib/initramfs/conf-hooks.d/zfs \
$(top_srcdir)/contrib/initramfs/README.initramfs.markdown

install-initrdSCRIPTS: $(EXTRA_DIST)
for d in conf.d conf-hooks.d hooks scripts scripts/local-top; do \
$(MKDIR_P) $(DESTDIR)$(initrddir)/$$d; \
cp $(top_srcdir)/contrib/initramfs/$$d/zfs \
$(MKDIR_P) -v $(DESTDIR)$(initrddir)/$$d; \
cp -v $(top_srcdir)/contrib/initramfs/$$d/zfs \
$(DESTDIR)$(initrddir)/$$d/; \
done
if [ -f etc/init.d/zfs ]; then \
$(MKDIR_P) $(DESTDIR)$(DEFAULT_INITCONF_DIR); \
cp $(top_srcdir)/etc/init.d/zfs \
$(DESTDIR)$(DEFAULT_INITCONF_DIR)/; \
fi

$(MKDIR_P) -v $(DESTDIR)$(DEFAULT_INITCONF_DIR) $(DESTDIR)/etc/zfs/

cp -v $(top_srcdir)/etc/init.d/zfs \
$(DESTDIR)$(DEFAULT_INITCONF_DIR)/

$(MKDIR_P) -v $(DESTDIR)/etc/init.d/

cp -v $(top_srcdir)/etc/init.d/zfs-functions \
$(DESTDIR)/etc/init.d/
20 changes: 17 additions & 3 deletions contrib/initramfs/hooks/zfs.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@
# Add ZoL filesystem capabilities to an initrd, usually for a native ZFS root.
#

# fail on errors; this might be annoying but for now it's more
# important to fail during initramfs creation where we can do
# something about it, vs after a boot when we can't
set -eu

# This hook installs udev rules for ZoL.
PREREQ="zdev"

# 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_FILE_LIST="/etc/hostid @sysconfdir@/zfs/zpool.cache"
COPY_FILE_LIST="$COPY_FILE_LIST @sysconfdir@/default/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@/69-vdev.rules"

# These are not required
OPTIONAL_FILE_LIST="/etc/hostid @sysconfdir@/default/zfs @sysconfdir@/zfs/vdev_id.conf"

# 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"
Expand Down Expand Up @@ -66,6 +71,15 @@ do
done

for ii in $COPY_FILE_LIST
do
dir=$(dirname "$ii")
[ -d "$dir" ] && mkdir -p "$DESTDIR/$dir"
[ -f "$ii" ] && cp -p "$ii" "$DESTDIR/$ii"
# error if missing
[ -e "$ii" ]
done

for ii in $OPTIONAL_FILE_LIST
do
dir=$(dirname "$ii")
[ -d "$dir" ] && mkdir -p "$DESTDIR/$dir"
Expand Down
2 changes: 2 additions & 0 deletions rpm/generic/zfs.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ systemctl --system daemon-reload >/dev/null || true
%if 0%{?_initramfs}
%files initramfs
%doc contrib/initramfs/README.initramfs.markdown
/etc/default/zfs
/etc/init.d/zfs-functions
/usr/share/initramfs-tools/*
%else
# Since we're not building the initramfs package,
Expand Down