postmarketos-initramfs: check for root subpartition (MR 5048)

In mount_subpartition we currently try to look for the boot partition,
to see if we're done (either we aren't using subpartitions or we found
the right one). However it is possible that a device might have
originally used the subpartition scheme, but was later converted to have
a real boot partition (for EFI for example).

In this scenario, the boot partition would be found immediately, but the
root subpartition would not be.

Address this by making mount_subpartition check for success by calling
find_root_partition instead of find_boot_partition. For most
installations this has no impact.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly authored and Clayton Craft committed 2024-06-26 17:32:33 -07:00
1 parent 0cd613c8b0
commit 7030e08e7b
1 file changed
+2 -2
@@ -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_boot_partition)" ]; do
while [ -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_boot_partition)" ]; then
if [ -n "$(find_root_partition)" ]; then
break
fi
kpartx -d "$partition"