Help with expanding partiton on SD card

I have installed a new instance of OpenWrt on a new 64GB SD card.
I installed the packages and issued the commands I found online,
yet I do not know if my card was expanded or not.
This is the procedure I did, was it the correct one

type opkg update and press enter
type opkg install parted losetup resize2fs
type wget -U "" -O expand-root.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=0"
NOW TYPE ../expand-root.sh <<< THIS DID NOT WORK, sh expand-root.sh DID NOT WORK
sh /expand-root.sh THREW UP NO ERROR SO AM HHOPING AFTER A reboot the entire SD
card will be available to use.```

This is what am seeing, is this card expanded or not, it is a 64GB card

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                98.3M     24.5M     71.8M  25% /
tmpfs                     3.8G    220.0K      3.8G   0% /tmp
/dev/mmcblk0p1           63.9M     19.1M     44.8M  30% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
1 Like

Rebooted ?

Yes, I rebooted, fdisk was not installed, does it need to be for the script sh /expand-root.sh to run. Or am I using the wrong command.
Using ../expand-root.sh causes a not permitted error, in the past I did
chmod +x /expand-root.sh and the error dissapeared, but for some reason
the router would no longer boot, could not log in to again so weary of this.

You're not telling us the hw you use, but I would check the PARTUUID post resize.

Rspberry Pi4

Device         Boot  Start    End Sectors  Size Id Type
/dev/mmcblk0p1 *      8192 139263  131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456 360447  212992  104M 83 Linux
root@OpenWrt:~# 

I've expanded 64 GB SD card on my Raspberry Pi4 (512MB total rootfs + rest for userspace). I'll copy paste my notes here feel free to ask me doubts

##### Automated (For 512MB Total Rootfs)
72MiB (Start)+512MiB (Size)= 584MiB (End)

# 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=0"
 
# 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

# Edit "/etc/uci-defaults/70-rootpt-resize" 584MiB => (72+512)

# Resize root partition and filesystem (will resize partiton, reboot resize filesystem, and reboot again)
sh /etc/uci-defaults/70-rootpt-resize

# Let it reboot. Confirm new partitions. Now Make 3rd partition.
parted -s /dev/mmcblk0 mkpart primary f2fs 584MiB 100%

#Format 3rd Big Partion (Optional)
mkfs.f2fs -l storage /dev/mmcblk0p3

# Restart. Then again go to Luci > Mount Points > Mount Points > Add. Select the partition from the UUID. Name it (/sda0). Choose f2fs filesystem from advanced. Save.
1 Like

@AlanDias17 am using a Raspberry Pi, and have no idea if the file system is the same.
There is no apk update command.

Then you're not using 25.12 but 24.10 or older.

update to latest firmware OpenWrt 25.12.1 squasfs sysupgrade using this sire: OpenWrt Firmware Selector

Packages I'm using:
Packages 1: apk-openssl base-files bcm27xx-utils ca-bundle dnsmasq dropbear e2fsprogs firewall4 fstools kmod-fs-vfat kmod-nft-offload kmod-nls-cp437 kmod-nls-iso8859-1 libc libgcc libustream-openssl logd mkf2fs mtd netifd nftables odhcp6c odhcpd-ipv6only partx-utils ppp ppp-mod-pppoe procd-ujail uci uclient-fetch urandom-seed cypress-firmware-43455-sdio brcmfmac-nvram-43455-sdio kmod-brcmfmac wpad-openssl kmod-usb-net-lan78xx kmod-usb-net-rtl8152 luci

Packages 2: kmod-tcp-bbr luci-app-samba4 luci-app-upnp block-mount wsdd2 kmod-netem luci-app-aria2 fdisk iperf3 luci-ssl-openssl curl bash tcpdump bind-tools

Packages 3: parted losetup resize2fs blkid

Am not much good with code.
I am following this tutorial from OpenWrt 's site and have no idea why my partition
table is not changing, should I get a success or fail message after submitting the last command.

# 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=0"
 
# 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

Yes, am using the following because it worked and I did not want to chance the newer version until its out for a while.

root@OpenWrt:/# ubus call system board
{
	"kernel": "6.6.119",
	"hostname": "OpenWrt",
	"system": "ARMv8 Processor rev 3",
	"model": "Raspberry Pi 4 Model B Rev 1.5",
	"board_name": "raspberrypi,4-model-b",
	"rootfs_type": "ext4",
	"release": {
		"distribution": "OpenWrt",
		"version": "24.10.5",
		"revision": "r29087-d9c5716d1d",
		"target": "bcm27xx/bcm2711",
		"description": "OpenWrt 24.10.5 r29087-d9c5716d1d",
		"builddate": "1766005702"
	}
}
root@OpenWrt:/# 

Did you follow the section at the bottom of the page about re-running the script?

2 Likes

I'll make steps simple.

  1. First you need to fresh upgrade your openwrt firmware to the latest version. Since your current version doesn't support apk (opkg is old now)
  2. Use the site and packages I provided to build the image. Will take time but keep patience.
  3. Download squashfs instead ext4 sysupgrade. Squasfs is optimal for NAND flash gates (SD cards) and upgrade firmware
  4. Follow the notes I provided.
1 Like

I have just downloaded the most up to date version, can I use that and follow your instructions.

yes sure if you have Discord I can help you there faster

These two files that they explain to remove do not exist on my system.
I have ext4 version on raspberry pi.

/etc/uci-defaults/70-rootpt-resize
/etc/uci-defaults/80-rootfs-resize

Run the script like this next time and post the results:

sh -x /etc/uci-defaults/70-rootpt-resize
2 Likes

This is for new people who want to increase their system space to 512MB and use the rest of your SD card (Example here 64GB) for storage:

Step 1: Install Necessary Tools

apk update
apk add parted resize2fs f2fs-tools fdisk
  • parted: Resizes the partition "walls."
  • resize2fs: Stretches the actual filesystem to fit the new walls.
  • f2fs-tools: Allows you to format the remaining 59GB.
  • fdisk: For verification

Step 2: Prepare the Expansion Script

  • Use an official script to automate the resizing logic
wget -U "" -O expand-root.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=0"
. ./expand-root.sh

This creates a temporary "startup task" that resizes the disk safely during the next boot.

Step 3: Set the 512MB Limit

By default, the script takes the whole card. We must tell it to stop at 584MiB (72MB Start + 512MB Size).

sed -i 's/100%/584MiB/' /etc/uci-defaults/70-rootpt-resize

This ensures your system stays at 512MB, leaving the rest of the 64GB card free for your data partition. Also we added the resize script to /etc/sysupgrade.conf, OpenWrt will remember our 512MB limit even after you upgrade to a newer version. It won't accidentally expand and overwrite your 59GB data partition!

Step 4: Apply and Reboot

  • Run the trigger script. Your Pi will reboot twice.

sh /etc/uci-defaults/70-rootpt-resize

Note: Wait 2 minutes. The first reboot resizes the partition; the second resizes the filesystem.

Step 5: Create the Data Partition

  • Now use the remaining ~59GB for a separate storage area.
# Create the partition wall
parted -a optimal -s /dev/mmcblk0 mkpart primary f2fs 584MiB 100%
# Format it so you can save files
mkfs.f2fs -l storage /dev/mmcblk0p3

Step 6: Final Setup in LuCI (Web Interface)

  • Go to System > Mount Points.
  • Find Mount Points and click Add.
  • UUID: Select the one ending in /dev/mmcblk0p3.
  • Mount Point: Type /sda0
  • Save & Apply, then reboot one last time.

Step 7: Confirm Your Work

  • Verify that all partitions are correctly sized and recognized by the system.
fdisk -l /dev/mmcblk0
  • mmcblk0p2: Should now end near 584M (your 512MB system partition).
  • mmcblk0p3: Should show the remaining ~59G (your data partition).

===========================================

Future Upgrade Steps

  1. Backup: Download your settings from System > Backup.
  2. Upgrade: During sysupgrade make sure these packages are present:
    parted, resize2fs, f2fs-tools.
    If these are missing, the automated resize script will fail and may brick your router.
  3. Restore: Upload your backup file and let the router reboot.
  4. Verify Partition: Run fdisk -l /dev/mmcblk0.
    • If p3 exists: Go to Mount Points and re-add it.
    • If p3 is missing: Run parted -a optimal -s /dev/mmcblk0 mkpart primary f2fs 584MiB 100%.
  5. Final Mount: Enable the partition in LuCI under Mount Points.
2 Likes

There's an ASU server that accepts larger rootfs sizes, efahl have posted it earlier.

1 Like

I'll check thanks. Found it. This is a lot simpler :grinning_face_with_smiling_eyes: