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 <noreply@anthropic.com>
This commit is contained in:
Aaron D. Lee
2026-01-08 12:36:06 -05:00
parent 3d4a340305
commit df6125d098

View File

@@ -76,11 +76,20 @@ gum style --foreground 245 "Current: $CURRENT_SIZE"
echo "" echo ""
if gum confirm "Expand filesystem to fill SD card?" --default=true; then 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 gum spin --spinner dot --title "Expanding filesystem..." -- sudo resize2fs "$ROOT_DEV" 2>/dev/null
NEW_SIZE=$(df -h / | awk 'NR==2 {print $2}') NEW_SIZE=$(df -h / | awk 'NR==2 {print $2}')
gum style --foreground 82 "✓ Expanded to: $NEW_SIZE" gum style --foreground 82 "✓ Expanded to: $NEW_SIZE"
else 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 fi
sleep 1 sleep 1