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 2024-04-17 18:45:34 +01:00 committed by Clayton Craft
parent 0cd613c8b0
commit 7030e08e7b
No known key found for this signature in database
GPG key ID: 4A4CED6D7EDF950A

View file

@ -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"