Created
July 28, 2025 03:32
-
-
Save ruzickap/4260df0f066f1a25c7129bde2f515bd6 to your computer and use it in GitHub Desktop.
OpenWRT - Expanding root partition and filesystem - 70-rootpt-resize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://openwrt.org/docs/guide-user/advanced/expand_root | |
if [ ! -e /etc/rootpt-resize ] && lock -n /var/lock/root-resize; then | |
( | |
set -eux | |
date | |
ROOT_BLK="$(readlink -f /sys/dev/block/"$(awk -e '$9=="/dev/root"{print $3}' /proc/self/mountinfo)")" | |
ROOT_DISK="/dev/$(basename "${ROOT_BLK%/*}")" | |
ROOT_PART="${ROOT_BLK##*[^0-9]}" | |
parted -f -s "${ROOT_DISK}" resizepart "${ROOT_PART}" 100% | |
mount_root done | |
if [ -e /boot/cmdline.txt ]; then | |
set -eux | |
NEW_UUID=`blkid ${ROOT_DISK}p${ROOT_PART} | sed -n 's/.*PARTUUID="\([^"]*\)".*/\1/p'` | |
sed -i "s/PARTUUID=[^ ]*/PARTUUID=${NEW_UUID}/" /boot/cmdline.txt | |
fi | |
) 2>&1 | tee -a /etc/rootpt-resize | |
reboot | |
fi | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment