From 0c3a45b2b124c273ff1156935b089bc34dc513c4 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Thu, 2 Jan 2025 12:17:22 +0100 Subject: [PATCH] Revert "fix(lvm,cryptroot extensions): introduce another variable to keep track of the physical partition/uuid and rootdevice/uuid seperately" This reverts commit 3ec24d40e8ec703c3731a9107cc04fc41976da2a. --- extensions/lvm.sh | 8 +++++++- lib/functions/image/partitioning.sh | 15 ++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/extensions/lvm.sh b/extensions/lvm.sh index 96200dda4c86..9500d8eeef9f 100644 --- a/extensions/lvm.sh +++ b/extensions/lvm.sh @@ -72,6 +72,12 @@ function post_create_partitions__setup_lvm() { function prepare_root_device__create_volume_group() { + LOOP=$(losetup -f) + [[ -z $LOOP ]] && exit_with_error "Unable to find free loop device" + check_loop_device "$LOOP" + losetup $LOOP ${SDCARD}.raw + partprobe $LOOP + display_alert "Using LVM root" "${EXTENSION}" "info" vgscan vgchange -a y ${LVM_VG_NAME} @@ -91,4 +97,4 @@ function post_umount_final_image__close_lvm() { # Deactivat the Volume Group vgchange -a n ${LVM_VG_NAME} display_alert "LVM deactivated volume group" "${EXTENSION}" "info" -} \ No newline at end of file +} diff --git a/lib/functions/image/partitioning.sh b/lib/functions/image/partitioning.sh index f9c0e9f0d6b1..773ed9501579 100644 --- a/lib/functions/image/partitioning.sh +++ b/lib/functions/image/partitioning.sh @@ -244,8 +244,6 @@ function prepare_partitions() { display_alert "Partitioning with the following options" "$partition_script_output" "debug" echo "${partition_script_output}" | run_host_command_logged sfdisk "${SDCARD}".raw || exit_with_error "Partitioning failed!" fi - - declare -g LOOP call_extension_method "post_create_partitions" <<- 'POST_CREATE_PARTITIONS' *called after all partitions are created, but not yet formatted* @@ -256,7 +254,7 @@ function prepare_partitions() { exec {FD}> /var/lock/armbian-debootstrap-losetup flock -x $FD - + declare -g LOOP #--partscan is using to force the kernel for scaning partition table in preventing of partprobe errors LOOP=$(losetup --show --partscan --find "${SDCARD}".raw) || exit_with_error "Unable to find free loop device" display_alert "Allocated loop device" "LOOP=${LOOP}" @@ -279,7 +277,6 @@ function prepare_partitions() { ## ROOT PARTITION ## if [[ -n $rootpart ]]; then - local physical_rootdevice="${LOOP}p${rootpart}" local rootdevice="${LOOP}p${rootpart}" call_extension_method "prepare_root_device" <<- 'PREPARE_ROOT_DEVICE' @@ -306,10 +303,6 @@ function prepare_partitions() { root_part_uuid="$(blkid -s UUID -o value ${LOOP}p${rootpart})" declare -g -r ROOT_PART_UUID="${root_part_uuid}" - physical_root_part_uuid="$(blkid -s UUID -o value $physical_rootdevice)" - declare -g -r PHYSICAL_ROOT_PART_UUID="${physical_root_part_uuid}" - display_alert "Physical root device" "$physical_rootdevice (UUID=${PHYSICAL_ROOT_PART_UUID})" "debug" - display_alert "Mounting rootfs" "$rootdevice (UUID=${ROOT_PART_UUID})" run_host_command_logged mount ${fscreateopt} $rootdevice $MOUNT/ @@ -317,7 +310,7 @@ function prepare_partitions() { local rootfs if [[ $CRYPTROOT_ENABLE == yes ]]; then # map the LUKS container partition via its UUID to be the 'cryptroot' device - echo "$CRYPTROOT_MAPPER UUID=${physical_root_part_uuid} none luks" >> $SDCARD/etc/crypttab + echo "$CRYPTROOT_MAPPER UUID=${root_part_uuid} none luks" >> $SDCARD/etc/crypttab rootfs=$rootdevice # used in fstab else rootfs="UUID=$(blkid -s UUID -o value $rootdevice)" @@ -376,7 +369,7 @@ function prepare_partitions() { if [[ -f $SDCARD/boot/armbianEnv.txt ]]; then display_alert "Found armbianEnv.txt" "${SDCARD}/boot/armbianEnv.txt" "debug" if [[ $CRYPTROOT_ENABLE == yes ]]; then - echo "rootdev=$rootdevice cryptdevice=UUID=${physical_root_part_uuid}:$CRYPTROOT_MAPPER" >> "${SDCARD}/boot/armbianEnv.txt" + echo "rootdev=$rootdevice cryptdevice=UUID=${root_part_uuid}:$CRYPTROOT_MAPPER" >> "${SDCARD}/boot/armbianEnv.txt" else echo "rootdev=$rootfs" >> "${SDCARD}/boot/armbianEnv.txt" fi @@ -395,7 +388,7 @@ function prepare_partitions() { display_alert "Found boot.ini" "${SDCARD}/boot/boot.ini" "debug" sed -i -e "s/rootfstype \"ext4\"/rootfstype \"$ROOTFS_TYPE\"/" $SDCARD/boot/boot.ini if [[ $CRYPTROOT_ENABLE == yes ]]; then - rootpart="UUID=${physical_root_part_uuid}" + rootpart="UUID=${root_part_uuid}" sed -i 's/^setenv rootdev .*/setenv rootdev "\/dev\/mapper\/'$CRYPTROOT_MAPPER' cryptdevice='$rootpart':'$CRYPTROOT_MAPPER'"/' $SDCARD/boot/boot.ini else sed -i 's/^setenv rootdev .*/setenv rootdev "'$rootfs'"/' $SDCARD/boot/boot.ini