postmarketos-initramfs: Handle rootfsopts= on kernel cmdline (MR 4288)

This also removes redundant code and handles mount failure/no filesystem
separately.

fixes #2242
This commit is contained in:
Steven Davies 2023-07-30 18:35:45 +01:00 committed by Clayton Craft
parent 73a033328e
commit 1e4c8238c3
No known key found for this signature in database
GPG key ID: 4A4CED6D7EDF950A
2 changed files with 30 additions and 22 deletions

View file

@ -1,7 +1,7 @@
# Maintainer: Oliver Smith <ollieparanoid@postmarketos.org>
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=postmarketos-initramfs
pkgver=1.2.0
pkgver=1.2.1
pkgrel=0
pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra"
url="https://postmarketos.org"
@ -69,5 +69,5 @@ bed319179bcd0b894d6267c7e73f2890db07bc07df71542936947dfb3bdb17fade8a7b4e7b577f27
3bc73f3a0d1de210444d9c45fab51fd4520e38b43ffbb76368f8ff854b990aa2f21c6356840c5a48eb9808e834eb885a6d581639a60707c26abf66fc20b70db9 00-initramfs-base.files
e984cd3033ce8752ebc71127828b964b46259a5263c2ebfab32c1394b674bcff464862ff00b8e920d3d31386c54ca0b94f84bc77580d275ecfeea33e76c07ef4 00-initramfs-extra-base.files
5a6252a02f46a4649a5aa7731a3f1bffd6eeca26b36bfd7ba1920dd6c72cceecfe0101da20d2f53850f1394a23f2dc1a61bfcfcf9c99ecdd26aec26df9a72d4e init.sh
a6358ca43f36d84d64da063db456fa7520eeb7bbdb457082e6959995166156245b08d9e7c1098b6f2f52974e7cbcc0b7719e4a0d3400a1d989c9e7b831303bb4 init_functions.sh
d5570ce96f501d3a1cb39d803d81770abaa27b4692c455034a7d69e14ae226ee07f8bd61fdd0a738c8a10528e0a984c9e8ebe47427c4cb3a801097381d8adc36 init_functions.sh
"

View file

@ -436,31 +436,39 @@ resize_root_filesystem() {
mount_root_partition() {
partition="$(find_root_partition)"
echo "Mount root partition ($partition) to /sysroot (read-only)"
rootfsopts=""
# shellcheck disable=SC2013
for x in $(cat /proc/cmdline); do
[ "$x" = "${x#pmos_rootfsopts=}" ] && continue
# Prepend a comma because this will be appended to "ro" below
rootfsopts=",${x#pmos_rootfsopts=}"
done
echo "Mount root partition ($partition) to /sysroot (read-only) with options ${rootfsopts#,}"
type="$(get_partition_type "$partition")"
case "$type" in
ext4)
echo "Detected ext4 filesystem"
modprobe ext4
mount -t ext4 -o ro "$partition" /sysroot
;;
f2fs)
echo "Detected f2fs filesystem"
modprobe f2fs
mount -t f2fs -o ro "$partition" /sysroot
;;
btrfs)
echo "Detected btrfs filesystem"
modprobe btrfs
mount -t btrfs -o ro "$partition" /sysroot
;;
*) echo "WARNING: Detected unsupported '$type' filesystem ($partition)." ;;
esac
if ! [ -e /sysroot/usr ]; then
echo "Detected $type filesystem"
if ! { [ "$type" = "ext4" ] || [ "$type" = "f2fs" ] || [ "$type" = "btrfs" ]; } then
echo "ERROR: Detected unsupported '$type' filesystem ($partition)."
show_splash "ERROR: unsupported '$type' filesystem ($partition)\\nhttps://postmarketos.org/troubleshooting"
loop_forever
fi
if ! modprobe "$type"; then
echo "INFO: unable to load module '$type' - maybe it's built in"
fi
if ! mount -t "$type" -o ro"$rootfsopts" "$partition" /sysroot; then
echo "ERROR: unable to mount root partition!"
show_splash "ERROR: unable to mount root partition\\nhttps://postmarketos.org/troubleshooting"
loop_forever
fi
if ! [ -e /sysroot/usr ]; then
echo "ERROR: root partition appeared to mount but does not contain a root filesystem!"
show_splash "ERROR: root partition does not contain a root filesystem\\nhttps://postmarketos.org/troubleshooting"
loop_forever
fi
}
# $1: path to the hooks dir