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