From 1259d74b099692c514578ef34d3b229b7eba90a3 Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Tue, 24 Sep 2024 12:19:27 +0200 Subject: [PATCH] main/postmarketos-initramfs: mount subpartitions if root or boot is missing (MR 5625) Commit 7030e08e7b2f ("postmarketos-initramfs: check for root subpartition (MR 5048)") changed the partition check in mount_subpartitions to look for the root partition instead of the boot partition, in order to mount subpartitions even if the pmOS_boot partition was already found. Unfortunately, this causes regressions for the opposite case: If we find a root partition, but the boot partition exists only as a subpartition then mount_subpartitions will return early, without actually making the boot partition accessible. This is easy to trigger if you have a different Linux distribution with an encrypted crypto_LUKS volume installed and then flash pmOS subpartitions to a single partition. find_root_partition() will return the crypto_LUKS partition (without checking if it belongs to pmOS) and the boot partition is not found. Fix both use cases by checking for root *and* boot partition. If any of them is not found, we try to mount the subpartitions. --- main/postmarketos-initramfs/APKBUILD | 6 +++--- main/postmarketos-initramfs/init_functions.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main/postmarketos-initramfs/APKBUILD b/main/postmarketos-initramfs/APKBUILD index 09c9628d4..a6aaa3096 100644 --- a/main/postmarketos-initramfs/APKBUILD +++ b/main/postmarketos-initramfs/APKBUILD @@ -1,8 +1,8 @@ # Maintainer: Caleb Connolly # Co-Maintainer: Clayton Craft pkgname=postmarketos-initramfs -pkgver=3.3.3 -pkgrel=2 +pkgver=3.3.4 +pkgrel=0 pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra" url="https://postmarketos.org" options="!check" # no tests @@ -93,6 +93,6 @@ sha512sums=" 929a8e6cca6b2b4ac6af89fc3912e80315f51c9bf6e9479124ccb7ebe9e99c6c1cafb98d3aa01b0a76a2f6e0071ba3eb86c7a2169a15c2e1788d69458bea3471 00-initramfs-base.files bc51380728c50584794dfed7a6b2b22258b9a31fc0b1aee2e196277e9846336228e6b48ce7af5e213edcc772addaac2c9b2bb344dcbbdb72b9c548c268393c40 00-initramfs-extra-base.files 7ea2c318e3b63b84ba8eb09e31dd74cdd9c86f5f4d8970ab54bb9213930e913c09728b60d429828007ea2dbb0472fd50dc3daae2efbe307babf854e4d8ecb238 init.sh -bb221ed9506e646f7d1def07fba3e41daf507d08fd7467b7742d27b352fea8bbf5438a53706e18fa23ccb93afad86e44d55ba50522168abb39acf797f012ca4b init_functions.sh +12c4db4cde4a015d1e94dd9f1552023c0facf221d015ff7a0a807ef976c42d8e89bae6cbbf06f9d68b0aa1b78b2bf8a03a3710c2b0c4957af6d818f3e8820da5 init_functions.sh ba3275a9af788c7c782322a22a0f144d5e50e3498ea6886486a29331f23ae89cd32d500a3635cfa7cab369afba92edc18aeca64ccbf0cd589061cce23d15b46c unudhcpd.conf " diff --git a/main/postmarketos-initramfs/init_functions.sh b/main/postmarketos-initramfs/init_functions.sh index c3e8a9d47..3f0567c88 100644 --- a/main/postmarketos-initramfs/init_functions.sh +++ b/main/postmarketos-initramfs/init_functions.sh @@ -150,7 +150,7 @@ mount_subpartitions() { attempt_start=$(get_uptime_seconds) wait_seconds=10 echo "Trying to mount subpartitions for $wait_seconds seconds..." - while [ -z "$(find_root_partition)" ]; do + while [ -z "$(find_boot_partition)" ] || [ -z "$(find_root_partition)" ]; do partitions="$android_parts $(grep -v "loop\|ram" < /proc/diskstats |\ sed 's/\(\s\+[0-9]\+\)\+\s\+//;s/ .*//;s/^/\/dev\//')" for partition in $partitions; do @@ -161,7 +161,7 @@ mount_subpartitions() { # Ensure that this was the *correct* subpartition # Some devices have mmc partitions that appear to have # subpartitions, but aren't our subpartition. - if [ -n "$(find_root_partition)" ]; then + if [ -n "$(find_boot_partition)" ] && [ -n "$(find_root_partition)" ]; then break fi kpartx -d "$partition"