Created
July 28, 2025 03:33
-
-
Save ruzickap/eb2ff36be6440526d54c6e04decb8325 to your computer and use it in GitHub Desktop.
OpenWRT - Expanding root partition and filesystem - 80-rootfs-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/rootfs-resize ] && [ -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_DEV="/dev/${ROOT_BLK##*/}" | |
LOOP_DEV="$(awk -e '$5=="/overlay"{print $9}' /proc/self/mountinfo)" | |
if [ -z "${LOOP_DEV}" ]; then | |
LOOP_DEV="$(losetup -f)" | |
losetup "${LOOP_DEV}" "${ROOT_DEV}" | |
fi | |
resize2fs -f "${LOOP_DEV}" | |
mount_root done | |
) 2>&1 | tee -a /etc/rootfs-resize | |
reboot | |
fi | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment