public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] expand-on-first-boot: search until no device mapper is used
@ 2024-04-17  6:55 Quirin Gylstorff
  2024-04-26  6:07 ` Uladzimir Bely
  0 siblings, 1 reply; 2+ messages in thread
From: Quirin Gylstorff @ 2024-04-17  6:55 UTC (permalink / raw)
  To: isar-users

From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

Device mapper block devices can be stacked e.g.
in case a hard disk is encrypted and uses lvm:
sda
+-sda1                  259:3    0 2G  0 part
  +-sda1_crypt          253:0    0 2G  0 crypt
    +-debian--vg-root   253:1    0 1G  0 lvm

So we should traverse the `slaves` until we reach the endpoint.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 .../expand-on-first-boot/files/expand-last-partition.sh        | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
index 84f1219f..0cb2ee21 100755
--- a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
+++ b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
@@ -12,6 +12,9 @@ set -e
 ROOT_DEV="$(findmnt / -o source -n)"
 ROOT_DEV_NAME=${ROOT_DEV##*/}
 ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth 1 -print -quit 2>/dev/null || true)
+while [ -d "${ROOT_DEV_SLAVE}/slaves" ]; do
+	ROOT_DEV_SLAVE=$(find "${ROOT_DEV_SLAVE}"/slaves -mindepth 1 -print -quit 2>/dev/null || true)
+done
 if [ -n "${ROOT_DEV_SLAVE}" ]; then
 	ROOT_DEV=/dev/${ROOT_DEV_SLAVE##*/}
 fi
-- 
2.43.0


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

end of thread, other threads:[~2024-04-26  6:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17  6:55 [PATCH] expand-on-first-boot: search until no device mapper is used Quirin Gylstorff
2024-04-26  6:07 ` Uladzimir Bely

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