openwrt/defaults/70-rootpt-resize

23 lines
583 B
Plaintext

# Copied from https://openwrt.org/docs/guide-user/advanced/expand_root
if [ ! -e /etc/rootpt-resize ] \
&& type parted > /dev/null \
&& lock -n /var/lock/root-resize
then
ROOT_BLK="$(readlink -f /sys/dev/block/"$(awk -e \
'$9=="/dev/root"{print $3}' /proc/self/mountinfo)")"
DEV_NAME=$(basename "${ROOT_BLK%/*}")
[ ${DEV_NAME%%[0-9]*} == mmcblk ] || exit 1
ROOT_DISK="/dev/${DEV_NAME}"
ROOT_PART="${ROOT_BLK##*[^0-9]}"
parted -l ---pretend-input-tty << EOI
ok
fix
EOI
parted -s "${ROOT_DISK}" resizepart "${ROOT_PART}" 100%
mount_root done
touch /etc/rootpt-resize
reboot
fi
exit 1