revert: expand-overlay back to only support mmcblk2 (eMMC)

This commit is contained in:
xiexiaobao 2026-06-28 12:12:54 +08:00
parent 991f971e6e
commit 122394651e

View File

@ -7,30 +7,23 @@ FLAG_FILE="/etc/expand-overlay.done"
[ -f "$FLAG_FILE" ] && exit 0
# Only run if root is on eMMC or USB TF card
# Only run if root is on eMMC
ROOT_DEV=$(mount | grep ' / ' | awk '{print $1}' | sed 's/p[0-9]*$//')
case "$ROOT_DEV" in
/dev/mmcblk0|/dev/mmcblk2) ;;
*) exit 0 ;;
esac
DISK="$ROOT_DEV"
DISK_P3="${DISK}p3"
DISK_P4="${DISK}p4"
[ "$ROOT_DEV" != "/dev/mmcblk2" ] && exit 0
# Save backup of original partition table
sfdisk -d $DISK > /etc/sfdisk.bak 2>/dev/null
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 $DISK 2>/dev/null
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 $DISK 2>/dev/null
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=$DISK_P4 bs=512 count=1 conv=notrunc,sync 2>/dev/null
echo "RESET000" | dd of=/dev/mmcblk2p4 bs=512 count=1 conv=notrunc,sync 2>/dev/null
touch "$FLAG_FILE"
exit 0