postmarketos-initramfs: load loop module before mount_subpartitions on combined initramfs

On devices using a combined initramfs, init_2nd.sh is exec'd directly
from the first stage without ever calling load_modules(). This means the
loop kernel module (CONFIG_BLK_DEV_LOOP=m) is not guaranteed to be
loaded before mount_subpartitions() runs, causing losetup to fail:

  losetup: /dev/sda13: failed to set up loop device: No such file or directory
  ERROR: failed to mount subpartitions!

On the split initramfs path (init.sh), load_modules is called explicitly
before jumping to init_2nd.sh, so this regression did not affect those
devices.

Fix by explicitly loading the loop module in mount_subpartitions(),
right before the loop that searches for partitions. This location was
suggested by Clayton Craft.

Regression introduced by: 86bdb82116 (use loop device for subpartitions)
Tested on: oneplus-cheeseburger (combined initramfs, msm8998, loop=m)

Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/8034>
This commit is contained in:
glats 2026-02-18 01:11:22 -03:00 committed by The Friendly Meow (merge) Bot
parent 67bc6ac0d3
commit 348a61895f
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

View file

@ -1,7 +1,7 @@
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
maintainer="Casey Connolly <kcxt@postmarketos.org>"
pkgname=postmarketos-initramfs
pkgver=3.9.2
pkgver=3.9.3
pkgrel=0
pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra"
url="https://postmarketos.org"
@ -120,7 +120,7 @@ ace852ba267b3408998970df6042603c8bec1d033066d1c30ed65f1be955fee8644b57882898f102
26e391a2c45e4317549153630d7398f01cf374d9a95e2587f0f7153017c50b6640950af60eab3b3fcadef2e8826295445ac1f45567716d3bd5d12e9c87df599b 00-initramfs-base.files
cc4db00caba184ad78062505415b3dadb8a32a94fe8484e4860bb6e63cd8700c8450066ce1242c496d9f063234bbab0fa40668f9c5112f3baeee30c5d405a1eb 00-initramfs-extra-base.files
e90596540805662211bd2a2e427ce7cc38f6a30023267f902e23f2bae136b6cd8f4f4716b8fb611be9d671a964edd2ecce03fa32bc8024e29b8375b0097fde0c init.sh
f0ade1bbcec95d75f2adb7e61d39d79aa5a39b6ca4401249c6c23b5ec1913eb0d271adee2311a27045f20060e84c9e3a187d00db11cfc51f4959ec388029a33e init_functions.sh
ce1361157eed25045e58a98fa9d68630198d6b671e335992c56e6fbc6f08b32ffa50804eefd8d9768a1475ffddd1244f56e2c82c8fa4b81227ab5420ba488264 init_functions.sh
6b4881f9b43c90ebcc70d7b7a192d26a2e3ce01c43b8536fe900c2ffaf74ef035803b9aa083e7a9d5c49c75be8ba6ff22997a037ae4f399e6ee5e1978c4b3f9c init_2nd.sh
61acb470a163fb50ad46752781b5ccc5dba6db9170e4250b4dcdfc7572d0316a7a36bc5a383026887a7a59364ee30917790e429b3fce9de590543d1d8410589c init_functions_2nd.sh
675e7d5bee39b2df7d322117f8dcaccc274d61beaf4d50ead19bbf2109446d64b1c0aa0c5b4f9846eb6c1c403418f28f6364eff4537ba41120fbfcbc484b7da7 mdev.conf

View file

@ -365,6 +365,10 @@ mount_subpartitions() {
attempt_start=$(get_uptime_seconds)
wait_seconds=10
echo "Trying to mount subpartitions for $wait_seconds seconds..."
# Subpartition init uses losetup, so make sure the loop module is loaded.
modprobe loop 2>/dev/null || true
find_root_partition
while [ -z "$PMOS_ROOT" ]; do
partitions="$android_parts $(grep -v "loop\|ram" < /proc/diskstats |\