emissary-firmware/misc/turris/omnia/uci-defaults/99-resize-disk.sh
William Petit 81360c3fda
Some checks reported errors
arcad/emissary-firmware/pipeline/head Something is wrong with the build of this commit
feat(turris,omnia): re-enable disk resizing
2023-04-26 15:55:13 +02:00

21 lines
466 B
Bash

#!/bin/sh
set -eo pipefail
block info
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 -y -f "$LOOP_DEVICE"
resize2fs "$LOOP_DEVICE"
rm -f /etc/uci-defaults/99-resize-disk.sh
reboot