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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user