Control: tags -1 +patch 

Hi,

please find a patch attached that enables NFSv4 with dracut for the
latest live-build.  I used to build and test images generated with:

  lb config noauto --distribution sid --debian-installer none \
                   --cache-packages true --archive-areas main \
                   --initramfs dracut-live --binary-image netboot

After that, make ./tftpboot/live/vmlinuz ./tftpboot/live/initrd.img and
./binary/live/filesystem.squashfs available in the network and PXE boot
with boot parameters like:

  netboot=nfs boot=live components \
  root=live:nfs4:10.1.2.3:/standard-dracut/live/filesystem.squashfs

or (copy to RAM):

  netboot=nfs boot=live components \
  root=live:nfs4:10.1.2.3:/standard-dracut/live/filesystem.squashfs \
  rd.live.ram=1

Best regards,

  Andi
>From f059d912ef93100adba1facf4a7ebf6712d7dd1a Mon Sep 17 00:00:00 2001
From: "Andreas B. Mundt" <a...@debian.org>
Date: Thu, 28 Nov 2024 22:10:45 +0100
Subject: [PATCH] Implement netbooting with dracut initramfs

---
 functions/configuration.sh    | 10 ++++++----
 scripts/build/binary_syslinux |  2 +-
 scripts/build/chroot_hacks    |  6 +++++-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/functions/configuration.sh b/functions/configuration.sh
index 712398e37..10a0a008d 100755
--- a/functions/configuration.sh
+++ b/functions/configuration.sh
@@ -303,7 +303,8 @@ Prepare_config ()
 
 	case "${LB_ARCHITECTURE}" in
 		amd64|i386)
-			if [ "${LB_INITRAMFS}" = "dracut-live" ]; then
+			if [ "${LB_INITRAMFS}" = "dracut-live" ] && \
+				[ "${LB_IMAGE_TYPE}" != "netboot" ]; then
 				LB_BOOTLOADER_BIOS="${LB_BOOTLOADER_BIOS:-grub-pc}"
 			else
 				LB_BOOTLOADER_BIOS="${LB_BOOTLOADER_BIOS:-syslinux}"
@@ -722,11 +723,12 @@ Validate_config_permitted_values ()
 			Echo_error "Currently unsupported/untested: grub-legacy and dracut."
 			exit 1
 		fi
-		if [ "${LB_BOOTLOADER_BIOS}" = "syslinux" ]; then
-			Echo_error "Currently unsupported/untested: syslinux and dracut."
+		if [ "${LB_BOOTLOADER_BIOS}" = "syslinux" ] && \
+				[ "${LB_IMAGE_TYPE}" != "netboot" ]; then
+			Echo_error "Currently unsupported/untested: syslinux and dracut without netboot."
 			exit 1
 		fi
-		if ! In_list "${LB_IMAGE_TYPE}" iso iso-hybrid; then
+		if ! In_list "${LB_IMAGE_TYPE}" iso iso-hybrid netboot; then
 			# The boot=live:CDLABEL requires a CD medium
 			Echo_error "Currently unsupported/untested: image type ${LB_IMAGE_TYPE} and dracut."
 			exit 1
diff --git a/scripts/build/binary_syslinux b/scripts/build/binary_syslinux
index 21587f2e3..4906f8643 100755
--- a/scripts/build/binary_syslinux
+++ b/scripts/build/binary_syslinux
@@ -37,7 +37,7 @@ Check_stagefile
 Acquire_lockfile
 
 case "${LB_INITRAMFS}" in
-	live-boot)
+	live-boot|dracut-live)
 		_INITRAMFS="live"
 		;;
 	*)
diff --git a/scripts/build/chroot_hacks b/scripts/build/chroot_hacks
index d16732a8c..c4823e6c2 100755
--- a/scripts/build/chroot_hacks
+++ b/scripts/build/chroot_hacks
@@ -68,7 +68,11 @@ case "${LB_INITRAMFS}" in
 		;;
 	dracut-live)
 		# Enable the live module (with a unique name)
-		echo "add_dracutmodules+=\" dmsquash-live \"" > chroot/etc/dracut.conf.d/20-live-module-${SOURCE_DATE_EPOCH}.conf
+		if [ "${LB_IMAGE_TYPE}"='netboot' ]; then
+			echo "add_dracutmodules+=\" livenet nfs \"" > chroot/etc/dracut.conf.d/20-live-module-${SOURCE_DATE_EPOCH}.conf
+		else
+			echo "add_dracutmodules+=\" dmsquash-live \"" > chroot/etc/dracut.conf.d/20-live-module-${SOURCE_DATE_EPOCH}.conf
+		fi
 		# This ensures that dracut uses the same filename as initramfs-tools
 		Chroot chroot dpkg-reconfigure dracut
 		rm -f chroot/etc/dracut.conf.d/20-live-module-${SOURCE_DATE_EPOCH}.conf
-- 
2.39.5

Reply via email to