2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-13 15:47:00 +00:00

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.
This commit is contained in:
Markus Hilger
2026-10-30 09:55:43 +01:00
parent 0c57184ef1
commit 8bec81fb95
2 changed files with 20 additions and 8 deletions
@@ -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
@@ -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