public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] installer: hide device-mapper root partitions from target device list
@ 2025-11-20  4:22 'Kasturi Shekar' via isar-users
  2025-11-26  9:46 ` Zhihang Wei
  0 siblings, 1 reply; 2+ messages in thread
From: 'Kasturi Shekar' via isar-users @ 2025-11-20  4:22 UTC (permalink / raw)
  To: isar-users; +Cc: Kasturi Shekar

Root filesystems exposed through device-mapper paths (e.g.,
/dev/mapper/verityroot or /dev/dm-0) were being included in the list of
installable block devices. Since these mapper devices represent the
active root filesystem, they must not appear as installation targets.
This change resolves the issue by detecting the underlying physical
device of the current root and skipping it during block device enumeration.

Signed-off-by: Kasturi Shekar <kasturi.shekar@siemens.com>
---
 .../files/usr/bin/deploy-image-wic.sh         | 61 +++++++++++++------
 1 file changed, 41 insertions(+), 20 deletions(-)

diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
index b5ea8119..a4e38876 100755
--- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
+++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
@@ -36,22 +36,39 @@ if ! $installer_unattended; then
     # inspired by poky/meta/recipes-core/initrdscripts/files/install-efi.sh
     target_device_list=""
     current_root_dev_type=$(findmnt / -o fstype -n)
+    exclude_list=()
+
     if [ "$current_root_dev_type" = "nfs" ]; then
         current_root_dev="nfs"
+        exclude_list+=("nfs")
     else
-        current_root_dev=$(readlink -f "$(findmnt / -o source -n)")
-        current_root_dev=${current_root_dev#\/dev/}
-    fi
+    # For normal or immutable systems, get the backing device of '/'
+        root_source=$(findmnt / -o source -n)
+        root_source_resolved=$(readlink -f "$root_source" 2>/dev/null || echo "$root_source")
+        current_root_dev=${root_source_resolved#/dev/}
+
+        # Always exclude the exact device mounted as /
+        exclude_list+=("$current_root_dev")
 
-    case $current_root_dev in
-        mmcblk*)
-            ;;
-        nvme*)
-            ;;
-        *)
-            current_root_dev=${current_root_dev%%[0-9]*}
-            ;;
-    esac
+        base_no_part=${current_root_dev%%[0-9]*}
+        if [ -n "$base_no_part" ]; then
+            exclude_list+=("$base_no_part")
+        fi
+
+        # If root is coming through a dm-* device (e.g., dm-verity),
+        # the actual physical devices appear under /sys/block/<dm>/slaves/.
+        # We must exclude those slaves as well, otherwise the installer
+        # might show the live USB stick as a valid target.
+        if [ -d "/sys/block/$current_root_dev/slaves" ]; then
+            for slave in /sys/block/"$current_root_dev"/slaves/*; do
+                [ -e "$slave" ] || continue
+                slave_dev=$(basename "$slave")
+                exclude_list+=("$slave_dev")
+                slave_base=${slave_dev%%[0-9]*}
+                [ -n "$slave_base" ] && exclude_list+=("$slave_base")
+            done
+        fi
+    fi
 
     echo "Searching for target device..."
 
@@ -102,14 +119,18 @@ if ! $installer_unattended; then
                 # skip ram device
                 ;;
             *)
-                case $device in
-                    $current_root_dev*)
-                    # skip the device we are running from
-                    ;;
-                    *)
-                        target_device_list="$target_device_list $device"
-                    ;;
-                esac
+                #skip any excluded devices (root and its slaves)
+                skip_device=0
+                for ex in "${exclude_list[@]}"; do
+                    if [[ "$device" == "$ex"* ]]; then
+                        skip_device=1
+                        break
+                    fi
+                done
+
+                if [ "$skip_device" -eq 0 ]; then
+                    target_device_list="$target_device_list $device"
+                fi
                 ;;
         esac
     done
-- 
2.39.5

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20251120042217.1759272-1-kasturi.shekar%40siemens.com.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-26  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-20  4:22 [PATCH] installer: hide device-mapper root partitions from target device list 'Kasturi Shekar' via isar-users
2025-11-26  9:46 ` Zhihang Wei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox