From d2f4f9759da1bb1f481a407ff7165421c0f6dc6e Mon Sep 17 00:00:00 2001 From: Cobra Date: Tue, 7 Apr 2026 16:44:22 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20SD=20flash=20mounting=20wrong=20partition?= =?UTF-8?q?=20=E2=80=94=20Armbian=20p1=3Dboot=20p2=3Drootfs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WiFi, SSH keys, root password, firstboot service were all being written to the FAT32 boot partition (p1) instead of the ext4 rootfs (p2). Detect the ext4 partition by filesystem type and mount that as MOUNT_POINT. --- operator_setup.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/operator_setup.sh b/operator_setup.sh index 5649d22..708ba8e 100755 --- a/operator_setup.sh +++ b/operator_setup.sh @@ -453,12 +453,25 @@ step "Running partprobe..." partprobe "/dev/${DEVICE}" || warn "partprobe failed (non-critical)" sleep 3 -step "Mounting to ${MOUNT_POINT}..." +step "Mounting rootfs to ${MOUNT_POINT}..." mkdir -p "$MOUNT_POINT" -# Try /dev/${DEVICE}1 (most common for single-partition images) -mount "/dev/${DEVICE}1" "$MOUNT_POINT" 2>/dev/null || mount "/dev/${DEVICE}p1" "$MOUNT_POINT" || error "Mount failed. Check device partitioning." +# Armbian images: p1=FAT32 boot, p2=ext4 rootfs. Mount the rootfs partition. +# Detect by filesystem type; fall back to p1 for single-partition images. +_ROOTFS_PART="" +for _try in "/dev/${DEVICE}2" "/dev/${DEVICE}p2"; do + if [[ -b "$_try" ]] && blkid "$_try" 2>/dev/null | grep -qi ext; then + _ROOTFS_PART="$_try" + break + fi +done +if [[ -n "$_ROOTFS_PART" ]]; then + mount "$_ROOTFS_PART" "$MOUNT_POINT" || error "Mount of rootfs (${_ROOTFS_PART}) failed" +else + # Single-partition image fallback + mount "/dev/${DEVICE}1" "$MOUNT_POINT" 2>/dev/null || mount "/dev/${DEVICE}p1" "$MOUNT_POINT" || error "Mount failed — could not locate ext4 rootfs partition" +fi -info "Mounted at ${MOUNT_POINT}" +info "Mounted at ${MOUNT_POINT} ($(blkid -o value -s TYPE "${_ROOTFS_PART:-/dev/${DEVICE}1}"))" # ══════════════════════════════════════════════════════════════════════════════ # 7. APPLY CONFIGURATION TO CARD