diff --git a/board/aarch64/bananapi-bpi-r3/genimage.cfg.in b/board/aarch64/bananapi-bpi-r3/genimage.cfg.in index c3734ad4..67d5413a 100644 --- a/board/aarch64/bananapi-bpi-r3/genimage.cfg.in +++ b/board/aarch64/bananapi-bpi-r3/genimage.cfg.in @@ -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" } } diff --git a/board/aarch64/friendlyarm-nanopi-r2s/genimage.cfg.in b/board/aarch64/friendlyarm-nanopi-r2s/genimage.cfg.in index 6a069181..8c0031b4 100644 --- a/board/aarch64/friendlyarm-nanopi-r2s/genimage.cfg.in +++ b/board/aarch64/friendlyarm-nanopi-r2s/genimage.cfg.in @@ -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" } } diff --git a/board/aarch64/raspberrypi-rpi64/genimage.cfg.in b/board/aarch64/raspberrypi-rpi64/genimage.cfg.in index 51e45bd2..8e7b356e 100644 --- a/board/aarch64/raspberrypi-rpi64/genimage.cfg.in +++ b/board/aarch64/raspberrypi-rpi64/genimage.cfg.in @@ -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" } } diff --git a/board/common/mkaux.sh b/board/common/mkaux.sh index 3f139452..0adf9f0f 100755 --- a/board/common/mkaux.sh +++ b/board/common/mkaux.sh @@ -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" } } diff --git a/board/common/rootfs/etc/fstab b/board/common/rootfs/etc/fstab index 6c56c7f7..fc5850c7 100644 --- a/board/common/rootfs/etc/fstab +++ b/board/common/rootfs/etc/fstab @@ -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 diff --git a/board/common/rootfs/usr/libexec/infix/mnt b/board/common/rootfs/usr/libexec/infix/mnt index 844db878..d46af0c6 100755 --- a/board/common/rootfs/usr/libexec/infix/mnt +++ b/board/common/rootfs/usr/libexec/infix/mnt @@ -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