16 lines
402 B
Bash
16 lines
402 B
Bash
#!/bin/sh
|
|
|
|
set -eo pipefail
|
|
|
|
DISK=/dev/mmcblk0
|
|
PARTITION="${DISK}p2"
|
|
|
|
parted -s -a opt "$DISK" "resizepart 2 100%"
|
|
|
|
FS_SIZE="$(unsquashfs -s "$PARTITION" | grep -o 'Filesystem size [0-9]* bytes' | grep -o '[0-9][0-9]*')"
|
|
FS_OFFSET="$(expr '(' "$FS_SIZE" + 65535 ')' / 65536 '*' 65536)"
|
|
LOOP_DEVICE="$(losetup -f --show -o "$FS_OFFSET" "$PARTITION")"
|
|
|
|
e2fsck -fy "$LOOP_DEVICE"
|
|
resize2fs "$LOOP_DEVICE"
|