expand-overlay now splits eMMC into: - p3 (3GB): overlay filesystem (system + configs) - p4 (~54GB): ext4 data partition -> /mnt/data/docker Docker data-root auto-configured to /mnt/data/docker on first boot.
30 lines
970 B
Bash
30 lines
970 B
Bash
#!/bin/sh
|
|
# /etc/uci-defaults/99-expand-overlay
|
|
# Stage 1: Resize p3 to 3GB, create p4 for Docker data.
|
|
# Auto-removed by uci-defaults after first run.
|
|
|
|
FLAG_FILE="/etc/expand-overlay.done"
|
|
|
|
[ -f "$FLAG_FILE" ] && exit 0
|
|
|
|
# Only run if root is on eMMC
|
|
ROOT_DEV=$(mount | grep ' / ' | awk '{print $1}' | sed 's/p[0-9]*$//')
|
|
[ "$ROOT_DEV" != "/dev/mmcblk2" ] && exit 0
|
|
|
|
# Save backup of original partition table
|
|
sfdisk -d /dev/mmcblk2 > /etc/sfdisk.bak 2>/dev/null
|
|
|
|
# Step 1: Resize partition 3 to exactly 3GB (3072 MiB)
|
|
# instead of expanding to fill the entire disk
|
|
echo ",3072M" | sfdisk -N 3 /dev/mmcblk2 2>/dev/null
|
|
|
|
# Step 2: Create partition 4 using the remaining space
|
|
# sfdisk -N 4 with ",+" = start after p3, fill to end
|
|
echo ",+" | sfdisk -N 4 /dev/mmcblk2 2>/dev/null
|
|
|
|
# Step 3: Write RESET marker on p4 so stage 2 knows to format it
|
|
echo "RESET000" | dd of=/dev/mmcblk2p4 bs=512 count=1 conv=notrunc,sync 2>/dev/null
|
|
|
|
touch "$FLAG_FILE"
|
|
exit 0
|