main/postmarketos-mkinitfs: mount /sysroot/boot (MR 1398)

Mount the boot partition at /sysroot/boot and keep it mounted, when
running the switch_root command. This way, OpenRC doesn't need to mount
it and possibly use the wrong partition. The OpenRC service does not use
the same logic to find the boot partition, in particular it does not
support the pmos_boot kernel parameter.

While at it, print the mountpoint and read-only/read-write arguments in
the mounting log message for both root and boot.

Fixes: #664
This commit is contained in:
Oliver Smith 2020-07-06 16:01:19 +02:00 committed by Bart Ribbers
parent 58ae4df2ef
commit 863ec713ba
No known key found for this signature in database
GPG key ID: 699D16185DAFAE61
3 changed files with 25 additions and 8 deletions

View file

@ -1,5 +1,5 @@
pkgname=postmarketos-mkinitfs pkgname=postmarketos-mkinitfs
pkgver=0.12.2 pkgver=0.12.3
pkgrel=0 pkgrel=0
pkgdesc="Tool to generate initramfs images for postmarketOS" pkgdesc="Tool to generate initramfs images for postmarketOS"
url="https://postmarketos.org" url="https://postmarketos.org"
@ -39,8 +39,8 @@ check() {
} }
sha512sums="5037cb7285bb7c0c40ca9e6df332d882ef9a8b379756c785f921e062dab1b7e7f3139d00897f69323a916d709ced4297fea8cbd3a13ebae575b873ec9e2cbfae 00-default.modules sha512sums="5037cb7285bb7c0c40ca9e6df332d882ef9a8b379756c785f921e062dab1b7e7f3139d00897f69323a916d709ced4297fea8cbd3a13ebae575b873ec9e2cbfae 00-default.modules
1d49db8a48ad513cc548b8a0ea23cc64518e71c93863155b4e9d2271fb46090506331c03d6955d693c8568c248ecc76b218efe4a6f6bba57c41c5f6d775dc61b init.sh.in 995b4d15e6b248d55d53221ec52674e62d74f0be539ac2ab26d4279544e2bece7aa58810dd831e1b2f08f0520fc9a8dff3ad4df52a46ef73f61e462f74f68c48 init.sh.in
ae7a7538f62616b9ee8b56b39531782c7d61ecb1679677d6bbe0f5e3ca228941bf2f340fead1d1abd971df30ff3059428d8f759660f53ec946ad8026e0e59c4b init_functions.sh 683b1784cc6572717dd805caabea38fac1780b03ff3540b888aab4fd91ccae404634874e6c9fa39f723186821a849844c6df1235bdcbf47b2de6b7f483c42178 init_functions.sh
7201d4640a3e9ead8a47ffd9916b068476b7d950760a84c37e02268c942d49896bc986da6bdee27e832639c90775354d68046a6475205d8d1da995b068120d8f mkinitfs.sh 7201d4640a3e9ead8a47ffd9916b068476b7d950760a84c37e02268c942d49896bc986da6bdee27e832639c90775354d68046a6475205d8d1da995b068120d8f mkinitfs.sh
5105fcc5f2094009937b378c8d383270f4fcd0133d0e60268806a7d09966613f4ebfa93d7e1b90b5d83d0c5b1664a0b3fc7562e52cc1e0ca6cd54ff442b03e84 mkinitfs_functions.sh 5105fcc5f2094009937b378c8d383270f4fcd0133d0e60268806a7d09966613f4ebfa93d7e1b90b5d83d0c5b1664a0b3fc7562e52cc1e0ca6cd54ff442b03e84 mkinitfs_functions.sh
c7a3c33daeb12b33ac72207191941c4d634f15c22958273b52af381a70ebaba1d3a9299483f0c447d9e66c560151fe7b9588bb4bbef2c8914f83185984ee4622 mkinitfs_test.sh" c7a3c33daeb12b33ac72207191941c4d634f15c22958273b52af381a70ebaba1d3a9299483f0c447d9e66c560151fe7b9588bb4bbef2c8914f83185984ee4622 mkinitfs_test.sh"

View file

@ -35,7 +35,7 @@ show_splash /splash-loading.ppm.gz
setup_usb_network setup_usb_network
start_udhcpd start_udhcpd
mount_boot_partition mount_boot_partition /boot
extract_initramfs_extra @INITRAMFS_EXTRA@ extract_initramfs_extra @INITRAMFS_EXTRA@
start_charging_mode start_charging_mode
wait_root_partition wait_root_partition
@ -44,12 +44,15 @@ unlock_root_partition
resize_root_filesystem resize_root_filesystem
mount_root_partition mount_root_partition
# Mount boot partition into sysroot, so OpenRC doesn't need to do it (#664)
umount /boot
mount_boot_partition /sysroot/boot "rw"
init="/sbin/init" init="/sbin/init"
setup_bootchart2 setup_bootchart2
# Switch root # Switch root
killall telnetd mdev msm-fb-refresher 2>/dev/null killall telnetd mdev msm-fb-refresher 2>/dev/null
umount /boot
umount /proc umount /proc
umount /sys umount /sys
umount /dev/pts umount /dev/pts

View file

@ -164,6 +164,11 @@ find_boot_partition() {
findfs LABEL="pmOS_boot" findfs LABEL="pmOS_boot"
} }
# $1: path
# $2: set to "rw" for read-write
# Mount the boot partition. It gets mounted twice, first at /boot (ro), then at
# /sysroot/boot (rw), after root has been mounted at /sysroot, so we can
# switch_root to /sysroot and have the boot partition properly mounted.
mount_boot_partition() { mount_boot_partition() {
partition=$(find_boot_partition) partition=$(find_boot_partition)
if [ -z "$partition" ]; then if [ -z "$partition" ]; then
@ -171,8 +176,17 @@ mount_boot_partition() {
show_splash /splash-noboot.ppm.gz show_splash /splash-noboot.ppm.gz
loop_forever loop_forever
fi fi
echo "Mount boot partition ($partition)"
mount -r "$partition" /boot if [ "$2" = "rw" ]; then
mount_opts=""
echo "Mount boot partition ($partition) to $1 (read-write)"
else
mount_opts="-o ro"
echo "Mount boot partition ($partition) to $1 (read-only)"
fi
# shellcheck disable=SC2086
mount $mount_opts "$partition" "$1"
} }
# $1: initramfs-extra path # $1: initramfs-extra path
@ -257,7 +271,7 @@ resize_root_filesystem() {
mount_root_partition() { mount_root_partition() {
partition="$(find_root_partition)" partition="$(find_root_partition)"
echo "Mount root partition ($partition)" echo "Mount root partition ($partition) to /sysroot (read-only)"
mount -t ext4 -o ro "$partition" /sysroot mount -t ext4 -o ro "$partition" /sysroot
if ! [ -e /sysroot/usr ]; then if ! [ -e /sysroot/usr ]; then
echo "ERROR: unable to mount root partition!" echo "ERROR: unable to mount root partition!"