Skip to content

Instantly share code, notes, and snippets.

@blizzardengle
Created February 8, 2022 22:37
Show Gist options
  • Save blizzardengle/50faf46fb384326fe259362c5bdc354e to your computer and use it in GitHub Desktop.
Save blizzardengle/50faf46fb384326fe259362c5bdc354e to your computer and use it in GitHub Desktop.
Resize the ext4 filesystem on OpenWrt after having resized the partition table.
opkg update
opkg install losetup resize2fs
BOOT="$(sed -n -e "/\s\/boot\s.*$/{s///p;q}" /etc/mtab)"
DISK="${BOOT%%[0-9]*}"
PART="$((${BOOT##*[^0-9]}+1))"
ROOT="${DISK}${PART}"
LOOP="$(losetup -f)"
losetup ${LOOP} ${ROOT}
fsck.ext4 -y ${LOOP}
resize2fs ${LOOP}
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment