From 8bec81fb9519fa29f810d5fac0bcc901319f0789 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 30 Oct 2026 09:55:43 +0100 Subject: [PATCH] Keep the image mounted when installing a diskless image to disk With installtodisk and confluent_imagemethod=untethered (or uncompressed) imageboot.sh first extracts the image to RAM and tears down the image mount and the cryptimg device. installimage then hands the empty /mnt/remote to image2disk.py, which wipes the target disk and fails with: FileNotFoundError: [Errno 2] No such file or directory: '/dev/mapper/cryptimg' Writing the image to disk never needs the RAM copy, so treat the image method as tethered when installtodisk is set. The same profile can then be switched between untethered and installtodisk by only adding or removing installtodisk. --- .../profiles/default/scripts/imageboot.sh | 14 ++++++++++---- .../profiles/default/scripts/imageboot.sh | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/confluent_osdeploy/el10-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/el10-diskless/profiles/default/scripts/imageboot.sh index 208a4e4c..9d0b45e2 100644 --- a/confluent_osdeploy/el10-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/el10-diskless/profiles/default/scripts/imageboot.sh @@ -4,8 +4,14 @@ if [[ "$confluent_whost" == *:* ]] && [[ "$confluent_whost" != "["* ]]; then confluent_whost="[$confluent_mgr]" fi mkdir -p /mnt/remoteimg /mnt/remote /mnt/overlay /sysroot +imagemethod=$(getarg confluent_imagemethod) +if grep installtodisk /proc/cmdline > /dev/null; then + # installimage copies from the mounted image, which an untethered or + # uncompressed boot would extract to RAM and unmount first + imagemethod=tethered +fi set_selinux_context system_u:object_r:bin_t:s0 /opt/confluent/bin/urlmount -if [ "untethered" = "$(getarg confluent_imagemethod)" -o "uncompressed" = "$(getarg confluent_imagemethod)" ]; then +if [ "untethered" = "$imagemethod" -o "uncompressed" = "$imagemethod" ]; then mount -t tmpfs untethered /mnt/remoteimg while ! curl -f https://$confluent_whost/confluent-public/os/$confluent_profile/rootimg.sfs -o /mnt/remoteimg/rootimg.sfs; do echo "Failed downloading image, retrying..." @@ -45,7 +51,7 @@ fi #mount -t tmpfs overlay /mnt/overlay -if [ ! "uncompressed" = "$(getarg confluent_imagemethod)" ]; then +if [ ! "uncompressed" = "$imagemethod" ]; then modprobe zram memtot=$(grep ^MemTotal: /proc/meminfo|awk '{print $2}') memtot=$((memtot/2))$(grep ^MemTotal: /proc/meminfo | awk '{print $3'}) @@ -53,8 +59,8 @@ if [ ! "uncompressed" = "$(getarg confluent_imagemethod)" ]; then mkfs.xfs /dev/zram0 > /dev/null fi TETHERED=0 -if [ "untethered" = "$(getarg confluent_imagemethod)" -o "uncompressed" = "$(getarg confluent_imagemethod)" ]; then - if [ "untethered" = "$(getarg confluent_imagemethod)" ]; then +if [ "untethered" = "$imagemethod" -o "uncompressed" = "$imagemethod" ]; then + if [ "untethered" = "$imagemethod" ]; then mount -o discard /dev/zram0 /sysroot else mount -t tmpfs disklessroot /sysroot diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/el9-diskless/profiles/default/scripts/imageboot.sh index 7ca1f1e9..7e8e881d 100644 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/el9-diskless/profiles/default/scripts/imageboot.sh @@ -4,7 +4,13 @@ if [[ "$confluent_whost" == *:* ]] && [[ "$confluent_whost" != "["* ]]; then confluent_whost="[$confluent_mgr]" fi mkdir -p /mnt/remoteimg /mnt/remote /mnt/overlay /sysroot -if [ "untethered" = "$(getarg confluent_imagemethod)" -o "uncompressed" = "$(getarg confluent_imagemethod)" ]; then +imagemethod=$(getarg confluent_imagemethod) +if grep installtodisk /proc/cmdline > /dev/null; then + # installimage copies from the mounted image, which an untethered or + # uncompressed boot would extract to RAM and unmount first + imagemethod=tethered +fi +if [ "untethered" = "$imagemethod" -o "uncompressed" = "$imagemethod" ]; then mount -t tmpfs untethered /mnt/remoteimg while ! curl -f https://$confluent_whost/confluent-public/os/$confluent_profile/rootimg.sfs -o /mnt/remoteimg/rootimg.sfs; do echo "Failed downloading image, retrying..." @@ -44,7 +50,7 @@ fi #mount -t tmpfs overlay /mnt/overlay -if [ ! "uncompressed" = "$(getarg confluent_imagemethod)" ]; then +if [ ! "uncompressed" = "$imagemethod" ]; then modprobe zram memtot=$(grep ^MemTotal: /proc/meminfo|awk '{print $2}') memtot=$((memtot/2))$(grep ^MemTotal: /proc/meminfo | awk '{print $3'}) @@ -52,8 +58,8 @@ if [ ! "uncompressed" = "$(getarg confluent_imagemethod)" ]; then mkfs.xfs /dev/zram0 > /dev/null fi TETHERED=0 -if [ "untethered" = "$(getarg confluent_imagemethod)" -o "uncompressed" = "$(getarg confluent_imagemethod)" ]; then - if [ "untethered" = "$(getarg confluent_imagemethod)" ]; then +if [ "untethered" = "$imagemethod" -o "uncompressed" = "$imagemethod" ]; then + if [ "untethered" = "$imagemethod" ]; then mount -o discard /dev/zram0 /sysroot else mount -t tmpfs disklessroot /sysroot