board/common: speed up mounting and boot

Reduce /var image size to 128M (resized at first boot anyway) and tune
mke2fs options for faster mounting.  Set ext4 'uninit_bg' feature and
use '-m 0 -i 4096' extraargs in genimage to optimize filesystem creation
and reduce overhead.  The genimage tool has several tweaks enabled by
default already, the 'uninit_bg' feature speeds up the time to check
the file system.

Disable periodic fsck with tune2fs at boot while keeping safety checks
intact.  Adjust mount options in fstab to reduce journal syncs and
improve boot time.

Fix severe performance regression in find_partition_by_label() that was
calling sgdisk on every block device including virtual devices (ram, loop,
dm-mapper). This caused boot delays of up to 24 seconds on systems with
many block devices. Now skip virtual devices that don't have GPT tables,
reducing the delay to ~2 seconds.

Also clean up is_mmc() function to use cached result.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-11-01 23:05:19 +01:00
parent b9e53e5721
commit 45efa9484e
6 changed files with 50 additions and 12 deletions
@@ -4,16 +4,23 @@ image cfg.ext4 {
size = 128M
ext4 {
label = "cfg"
use-mke2fs = true
features = "uninit_bg"
extraargs = "-m 0 -i 4096"
}
}
# The /var partition will be expanded automatically at first boot
# to use the full size of the SD-card or eMMC media.
image var.ext4 {
empty = true
temporary = true
size = 1G
size = 128M
ext4 {
label = "var"
use-mke2fs = true
features = "uninit_bg"
extraargs = "-m 0 -i 4096"
}
}
@@ -5,17 +5,24 @@ image cfg.ext4 {
ext4 {
label = "cfg"
use-mke2fs = true
features = "uninit_bg"
extraargs = "-m 0 -i 4096"
}
}
# The /var partition will be expanded automatically at first boot
# to use the full size of the SD-card or eMMC media.
image var.ext4 {
empty = true
temporary = true
size = 512M
size = 128M
ext4 {
label = "var"
use-mke2fs = true
use-mke2fs = true
features = "uninit_bg"
extraargs = "-m 0 -i 4096"
}
}
@@ -15,17 +15,24 @@ image cfg.ext4 {
ext4 {
label = "cfg"
use-mke2fs = true
features = "uninit_bg"
extraargs = "-m 0 -i 4096"
}
}
# The /var partition will be expanded automatically at first boot
# to use the full size of the SD-card or eMMC media.
image var.ext4 {
empty = true
temporary = true
size = 512M
size = 128M
ext4 {
label = "var"
use-mke2fs = true
use-mke2fs = true
features = "uninit_bg"
extraargs = "-m 0 -i 4096"
}
}
+2 -1
View File
@@ -11,7 +11,8 @@ image aux.ext4 {
ext4 {
label = "aux"
use-mke2fs = true
features = "^metadata_csum,^metadata_csum_seed"
features = "^metadata_csum,^metadata_csum_seed,uninit_bg"
extraargs = "-m 0 -i 4096"
}
}
+6 -6
View File
@@ -15,9 +15,9 @@ cfgfs /config configfs nofail,noauto 0 0
# The chosen backing storage for the overlays placed on /cfg, /etc,
# /home, /root, and /var, are determined dynamically by /usr/libexec/infix/mnt
# depending on the available devices.
mnttmp /mnt/tmp tmpfs defaults 0 0
LABEL=aux /mnt/aux auto noatime,nodiratime,noauto 0 0
LABEL=var /mnt/var auto noatime,nodiratime,noauto 0 0
LABEL=cfg /mnt/cfg auto noatime,nodiratime,noauto 0 0
hostfs /mnt/host 9p cache=none,msize=16384,noauto 0 0
/usr/libexec/infix/mnt# /cfg helper none 0 0
mnttmp /mnt/tmp tmpfs defaults 0 0
LABEL=aux /mnt/aux auto noatime,nodiratime,noauto,commit=30,errors=remount-ro 0 0
LABEL=var /mnt/var auto noatime,nodiratime,noauto,commit=30,errors=remount-ro 0 0
LABEL=cfg /mnt/cfg auto noatime,nodiratime,noauto,commit=30,errors=remount-ro 0 0
hostfs /mnt/host 9p cache=none,msize=16384,noauto 0 0
/usr/libexec/infix/mnt# /cfg helper none 0 0
+16
View File
@@ -19,6 +19,7 @@ set -e
nm=$(basename "$0")
err=0
mmc=""
opt="-k"
# External button or bootloader changed kernel command line
@@ -53,17 +54,22 @@ factory_reset()
is_mmc()
{
[ -n "$mmc" ] && return $mmc
# Check if primary or secondary partition (our rootfs) is on MMC
for label in primary secondary; do
devname=$(find_partition_by_label "$label" 2>/dev/null)
if [ -n "$devname" ]; then
case "$devname" in
mmcblk*)
mmc=0
return 0
;;
esac
fi
done
mmc=1
return 1
}
@@ -89,8 +95,15 @@ find_partition_by_label()
for diskpath in /sys/class/block/*; do
devname=$(basename "$diskpath")
# Skip partitions, only check whole disks
[ -f "$diskpath/partition" ] && continue
# Skip ram, loop, and other virtual devices
case "$devname" in
ram*|loop*|nullb*|dm-*) continue ;;
esac
disk="/dev/$devname"
result=$(sgdisk -p "$disk" 2>/dev/null | awk -v label="$label" -v devname="$devname" '
/^ *[0-9]/ {
@@ -275,6 +288,9 @@ mount_rw()
fi
# TODO: Also look for UBI partitions
#
tune2fs -c 0 -i 0 LABEL="$1" 2>/dev/null
mount LABEL="$1" 2>/dev/null && return 0
return 1