Skip to content

Commit

Permalink
Revert "fix(lvm,cryptroot extensions): introduce another variable to …
Browse files Browse the repository at this point in the history
…keep track of the physical partition/uuid and rootdevice/uuid seperately"

This reverts commit 3ec24d4.
  • Loading branch information
igorpecovnik committed Jan 3, 2025
1 parent bbb2976 commit 0c3a45b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 7 additions & 1 deletion extensions/lvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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"
}
}
15 changes: 4 additions & 11 deletions lib/functions/image/partitioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand All @@ -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}"
Expand All @@ -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'
Expand All @@ -306,18 +303,14 @@ 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/

# create fstab (and crypttab) entry
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)"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0c3a45b

Please sign in to comment.