From 0decb39b17bf5f58ef42183e4823ff4cbbdc5870 Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Thu, 8 Jan 2026 12:00:47 -0500 Subject: [PATCH] Move filesystem expansion to first-boot wizard Instead of a hidden systemd service, expand the filesystem visibly during the first-boot wizard so users can see it happening. Co-Authored-By: Claude Opus 4.5 --- rpi/first-boot-wizard.sh | 22 ++++++++++++++++++++++ rpi/pull-image.sh | 31 ------------------------------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/rpi/first-boot-wizard.sh b/rpi/first-boot-wizard.sh index 59dc4fb..8f1fe47 100755 --- a/rpi/first-boot-wizard.sh +++ b/rpi/first-boot-wizard.sh @@ -53,6 +53,28 @@ echo "" gum confirm "Ready to begin setup?" || exit 0 +# ============================================================================= +# Step 0: Expand Filesystem +# ============================================================================= + +clear +gum style \ + --foreground 212 --bold \ + "Expanding filesystem..." +echo "" + +# Get current and total size +ROOT_DEV=$(findmnt -n -o SOURCE /) +CURRENT_SIZE=$(df -h / | awk 'NR==2 {print $2}') +gum style --foreground 245 "Current size: $CURRENT_SIZE" + +# Run resize2fs with a spinner +gum spin --spinner dot --title "Expanding to fill SD card..." -- sudo resize2fs "$ROOT_DEV" 2>/dev/null + +NEW_SIZE=$(df -h / | awk 'NR==2 {print $2}') +gum style --foreground 82 "✓ Expanded to: $NEW_SIZE" +sleep 1 + # ============================================================================= # Configuration Variables # ============================================================================= diff --git a/rpi/pull-image.sh b/rpi/pull-image.sh index 3b663d3..b290aa6 100755 --- a/rpi/pull-image.sh +++ b/rpi/pull-image.sh @@ -123,37 +123,6 @@ else echo -e "${GREEN} Rootfs already ~16GB${NC}" fi -# ============================================================================ -# Re-enable auto-expand for release image -# ============================================================================ -echo -echo -e "${YELLOW}Re-enabling auto-expand for release...${NC}" -TEMP_ROOT=$(mktemp -d) -sudo mount "$ROOT_PART" "$TEMP_ROOT" - -# Create the resize service that runs on first boot -sudo tee "$TEMP_ROOT/etc/systemd/system/rpi-resizerootfs.service" > /dev/null <<'RESIZE_EOF' -[Unit] -Description=Resize root filesystem to fill SD card -After=local-fs.target - -[Service] -Type=oneshot -ExecStart=/bin/bash -c 'resize2fs $(findmnt -n -o SOURCE /) && systemctl disable rpi-resizerootfs.service && rm -f /etc/systemd/system/rpi-resizerootfs.service' -ExecStartPost=/bin/systemctl daemon-reload - -[Install] -WantedBy=multi-user.target -RESIZE_EOF - -# Enable the service -sudo mkdir -p "$TEMP_ROOT/etc/systemd/system/multi-user.target.wants" -sudo ln -sf /etc/systemd/system/rpi-resizerootfs.service "$TEMP_ROOT/etc/systemd/system/multi-user.target.wants/rpi-resizerootfs.service" - -sudo umount "$TEMP_ROOT" -rmdir "$TEMP_ROOT" -echo -e "${GREEN} Auto-expand service installed${NC}" - # ============================================================================ # Pull image # ============================================================================