Expanding root partition and filesystem
- extroot_configuration provides an alternative way of creating a exroot partition.
Introduction
These instructions can be used to expand the root partition and filesystem of your OpenWrt install on an x86 target which was installed using ext4 or squashfs images.
Features
- Support
ext4andsquashfsimage types. - Automatically identify the root partition and filesystem.
- Expand the root partition and filesystem using free space.
- Preserve the scripts through firmware upgrade.
- Automatically run after firmware upgrade.
Instructions
The instructions below can be used to download and execute a script which will perform the expansion automatically.
Do not follow these instructions if you have an NVMe device. There is currently a long standing issue with NVMe devices where these instructions will effectively brick your install after the first reboot with error:
failed to execute /usr/libexec/login.
If you are using an NVMe device, you will need to use an installation method that doesn't require you to image your NVMe device and expand it. For example, manually creating partitions, installing grub, formatting the root partition and copying in the files from rootfs.tar.gz.
OpenWrt Versions >= 25.12
# Install packages apk update apk add parted losetup resize2fs blkid # Download expand-root.sh wget -U "" -O expand-root.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=3" chmod +x expand-root.sh # Source the script (creates /etc/uci-defaults/70-rootpt-resize and /etc/uci-defaults/80-rootfs-resize, and adds them to /etc/sysupgrade.conf so they will be re-run after a sysupgrade) . ./expand-root.sh # Resize root partition and filesystem (will resize partiton, reboot resize filesystem, and reboot again) sh /etc/uci-defaults/70-rootpt-resize
OpenWrt Versions < 25.12
# Install packages opkg update opkg install parted losetup resize2fs blkid # Download expand-root.sh wget -U "" -O expand-root.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=3" # Source the script (creates /etc/uci-defaults/70-rootpt-resize and /etc/uci-defaults/80-rootpt-resize, and adds them to /etc/sysupgrade.conf so they will be re-run after a sysupgrade) . ./expand-root.sh # Resize root partition and filesystem (will resize partiton, reboot resize filesystem, and reboot again) sh /etc/uci-defaults/70-rootpt-resize
Manual Instructions
Troubleshooting
If the root partition has already been expanded and the expand-root.sh script has previously run, attempting to run it again will not work by default.
To perform an additional root expansion, you need remove previous script flags:
rm /etc/rootpt-resize rm /etc/rootfs-resize
Open the /etc/sysupgrade.conf file and remove the following lines:
/etc/uci-defaults/70-rootpt-resize /etc/uci-defaults/80-rootfs-resize
This ensures that the system no longer considers the scripts as already executed and then you can re-run script.