From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CDAF472ADE for ; Wed, 16 Jun 2021 12:56:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CB5F310B99 for ; Wed, 16 Jun 2021 12:56:48 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 5EC7C10B65 for ; Wed, 16 Jun 2021 12:56:47 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 385BD420CE for ; Wed, 16 Jun 2021 12:56:47 +0200 (CEST) From: Stefan Reiter To: pbs-devel@lists.proxmox.com Date: Wed, 16 Jun 2021 12:55:49 +0200 Message-Id: <20210616105552.2594536-3-s.reiter@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616105552.2594536-1-s.reiter@proxmox.com> References: <20210616105552.2594536-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.782 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [autogen.sh, main.rs] Subject: [pbs-devel] [PATCH proxmox-backup-restore-image 2/5] build custom ZFS tools without udev requirement X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2021 10:56:48 -0000 We already include the required sources with the zfsonlinux submodule, so apply a patch to disable linking against libudev (as I couldn't find a working configure flag for it?) and build the user space part as well. Includes dependencies as well as 'strace' for the debug initramfs, which proved quite useful for debugging. The init-shim automatically creates the necessary /dev/zfs device node, and additionally /dev/null to make rust's std::process::Command happy. Signed-off-by: Stefan Reiter --- src/Makefile | 21 +++++++- src/build_initramfs.sh | 19 ++++++- src/init-shim-rs/src/main.rs | 10 ++++ .../0001-remove-reference-to-libudev.patch | 52 +++++++++++++++++++ 4 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/patches/zfs/0001-remove-reference-to-libudev.patch diff --git a/src/Makefile b/src/Makefile index a398ea1..053be5f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,6 +11,8 @@ KERNEL_IMG=${BUILDDIR}/bzImage INITRAMFS_IMG=${INITRAMFS_BUILDDIR}/initramfs.img INITRAMFS_IMG_DBG=${INITRAMFS_BUILDDIR}/initramfs-debug.img +ZFS_TOOLS=${BUILDDIR}/zfstools + CONFIG=config-base RUST_SRC=$(wildcard ${SHIM_DIR}/**/*.rs) ${SHIM_DIR}/Cargo.toml @@ -35,6 +37,10 @@ kernel.prepared: ${BUILDDIR}.prepared touch $@ zfs.prepared: kernel.prepared + cd ${BUILDDIR}/${ZFSONLINUX_SUBMODULE}; \ + for p in ../../patches/zfs/*.patch; do \ + patch -Np1 < $$p; \ + done cd ${BUILDDIR}/${ZFSONLINUX_SUBMODULE}; \ sh autogen.sh && \ ./configure \ @@ -51,7 +57,20 @@ ${KERNEL_IMG}: zfs.prepared cd ${BUILDDIR}/${KERNEL_SUBMODULE}; $(MAKE) mv ${BUILDDIR}/${KERNEL_SUBMODULE}/arch/x86/boot/bzImage ${KERNEL_IMG} -${INITRAMFS_IMG}: ${BUILDDIR}.prepared ${RUST_SRC} build_initramfs.sh +${ZFS_TOOLS}: zfs.prepared + cd ${BUILDDIR}/${ZFSONLINUX_SUBMODULE}; \ + ./configure \ + --bindir=/usr/bin \ + --sbindir=/sbin \ + --libdir=/lib/"$(DEB_HOST_MULTIARCH)" \ + --with-zfsexecdir=/usr/lib/zfs-linux \ + --disable-systemd \ + --disable-pyzfs \ + --with-config=user + # absolute path required for 'make install' + $(MAKE) -C ${BUILDDIR}/${ZFSONLINUX_SUBMODULE} install DESTDIR=${PWD}/${ZFS_TOOLS} + +${INITRAMFS_IMG}: ${BUILDDIR}.prepared ${RUST_SRC} build_initramfs.sh ${ZFS_TOOLS} cd ${SHIM_DIR}; cargo build --release sh build_initramfs.sh diff --git a/src/build_initramfs.sh b/src/build_initramfs.sh index c4ee95c..29eeedb 100755 --- a/src/build_initramfs.sh +++ b/src/build_initramfs.sh @@ -19,9 +19,10 @@ add_pkgs() { LOCAL_DEPS=$(apt-rdepends -f Depends -s Depends "$pkg" | grep -v '^ ') DEPS="$DEPS $LOCAL_DEPS" done - # debconf and gcc are unnecessary + # debconf and gcc are unnecessary, libboost-regex doesn't install on bullseye DEPS=$(echo "$DEPS" |\ sed -E 's/debconf(-2\.0)?//' |\ + sed -E 's/libboost-regex//' |\ sed -E 's/gcc-.{1,2}-base//') apt-get download $DEPS for deb in ./*.deb; do @@ -47,8 +48,23 @@ add_pkgs " libstdc++6:amd64 \ libssl1.1:amd64 \ libacl1:amd64 \ + libblkid1:amd64 \ + libuuid1:amd64 \ + zlib1g:amd64 \ " + +# install custom ZFS tools (built without libudev) +mkdir -p "$ROOT/sbin" +cp -a ../zfstools/sbin/* "$ROOT/sbin/" +cp -a ../zfstools/etc/* "$ROOT/etc/" +cp -a ../zfstools/lib/* "$ROOT/lib/" +cp -a ../zfstools/usr/* "$ROOT/usr/" + rm -rf ${ROOT:?}/usr/share # contains only docs and debian stuff +rm -rf ${ROOT:?}/usr/local/include # header files +rm -rf ${ROOT:?}/usr/local/share # mostly ZFS tests +rm -f ${ROOT:?}/lib/x86_64-linux-gnu/*.a # static libraries + make_cpio "initramfs.img" # add debug helpers for debug initramfs, packages from above are included too @@ -56,6 +72,7 @@ add_pkgs " util-linux:amd64 \ busybox-static:amd64 \ gdb:amd64 \ + strace:amd64 \ " # leave /usr/share here, it contains necessary stuff for gdb make_cpio "initramfs-debug.img" diff --git a/src/init-shim-rs/src/main.rs b/src/init-shim-rs/src/main.rs index 641218f..62d7e99 100644 --- a/src/init-shim-rs/src/main.rs +++ b/src/init-shim-rs/src/main.rs @@ -6,6 +6,10 @@ use std::process::Command; const URANDOM_MAJ: u64 = 1; const URANDOM_MIN: u64 = 9; +const ZFS_MAJ: u64 = 10; +const ZFS_MIN: u64 = 249; +const NULL_MAJ: u64 = 1; +const NULL_MIN: u64 = 3; /// Set up a somewhat normal linux userspace environment before starting the restore daemon, and /// provide error messages to the user if doing so fails. @@ -22,6 +26,12 @@ fn main() { wrap_err("mknod /dev/urandom", || { do_mknod("/dev/urandom", URANDOM_MAJ, URANDOM_MIN) }); + wrap_err("mknod /dev/zfs", || { + do_mknod("/dev/zfs", ZFS_MAJ, ZFS_MIN) + }); + wrap_err("mknod /dev/null", || { + do_mknod("/dev/null", NULL_MAJ, NULL_MIN) + }); if let Err(err) = run_agetty() { // not fatal diff --git a/src/patches/zfs/0001-remove-reference-to-libudev.patch b/src/patches/zfs/0001-remove-reference-to-libudev.patch new file mode 100644 index 0000000..467d9b5 --- /dev/null +++ b/src/patches/zfs/0001-remove-reference-to-libudev.patch @@ -0,0 +1,52 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Stefan Reiter +Date: Thu, 10 Jun 2021 10:50:22 +0200 +Subject: [PATCH] remove reference to libudev + +since there's no command line flag I can see... + +Signed-off-by: Stefan Reiter +--- + config/user-libudev.m4 | 17 ----------------- + config/user.m4 | 1 - + 2 files changed, 18 deletions(-) + delete mode 100644 config/user-libudev.m4 + +diff --git a/config/user-libudev.m4 b/config/user-libudev.m4 +deleted file mode 100644 +index 8c3c1d7e0..000000000 +--- a/config/user-libudev.m4 ++++ /dev/null +@@ -1,17 +0,0 @@ +-dnl # +-dnl # Check for libudev - needed for vdev auto-online and auto-replace +-dnl # +-AC_DEFUN([ZFS_AC_CONFIG_USER_LIBUDEV], [ +- ZFS_AC_FIND_SYSTEM_LIBRARY(LIBUDEV, [libudev], [libudev.h], [], [udev], [], [user_libudev=yes], [user_libudev=no]) +- +- AS_IF([test "x$user_libudev" = xyes], [ +- AX_SAVE_FLAGS +- +- CFLAGS="$CFLAGS $LIBUDEV_CFLAGS" +- LIBS="$LIBUDEV_LIBS $LIBS" +- +- AC_CHECK_FUNCS([udev_device_get_is_initialized]) +- +- AX_RESTORE_FLAGS +- ]) +-]) +diff --git a/config/user.m4 b/config/user.m4 +index c22067551..1b6d3a24e 100644 +--- a/config/user.m4 ++++ b/config/user.m4 +@@ -18,7 +18,6 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ + ZFS_AC_CONFIG_USER_LIBBLKID + ]) + ZFS_AC_CONFIG_USER_LIBTIRPC +- ZFS_AC_CONFIG_USER_LIBUDEV + ZFS_AC_CONFIG_USER_LIBCRYPTO + ZFS_AC_CONFIG_USER_LIBAIO + ZFS_AC_CONFIG_USER_CLOCK_GETTIME +-- +2.30.2 + -- 2.30.2