From df6125d0985977f0e23671cb83a4de37d29fdf17 Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Thu, 8 Jan 2026 12:36:06 -0500 Subject: [PATCH] Use growpart before resize2fs to expand full disk resize2fs only fills the partition. Need growpart first to expand the partition to fill the disk, then resize2fs to expand the filesystem. Co-Authored-By: Claude Opus 4.5 --- rpi/first-boot-wizard.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rpi/first-boot-wizard.sh b/rpi/first-boot-wizard.sh index 0038c6c..bb806a8 100755 --- a/rpi/first-boot-wizard.sh +++ b/rpi/first-boot-wizard.sh @@ -76,11 +76,20 @@ gum style --foreground 245 "Current: $CURRENT_SIZE" echo "" if gum confirm "Expand filesystem to fill SD card?" --default=true; then + # Get the disk device (strip partition number) and partition number + DISK_DEV=$(echo "$ROOT_DEV" | sed 's/p\?[0-9]*$//') + PART_NUM=$(echo "$ROOT_DEV" | grep -o '[0-9]*$') + + # Step 1: Grow partition to fill disk + gum spin --spinner dot --title "Expanding partition..." -- sudo growpart "$DISK_DEV" "$PART_NUM" 2>/dev/null || true + + # Step 2: Resize filesystem to fill partition gum spin --spinner dot --title "Expanding filesystem..." -- sudo resize2fs "$ROOT_DEV" 2>/dev/null + NEW_SIZE=$(df -h / | awk 'NR==2 {print $2}') gum style --foreground 82 "✓ Expanded to: $NEW_SIZE" else - gum style --foreground 214 "→ Skipped (you can run 'sudo resize2fs $ROOT_DEV' later)" + gum style --foreground 214 "→ Skipped (run 'sudo growpart /dev/sdX 2 && sudo resize2fs /dev/sdX2' later)" fi sleep 1