Resize partition fails

I was doing this:

opkg update
opkg install parted
BOOT="$(sed -n -e "\|\s/boot\s.*$|{s///p;q}" /etc/mtab)"
DISK="${BOOT%%[0-9]*}"
PART="$((${BOOT##*[^0-9]}+1))"
echo fix | parted -l ---pretend-input-tty
parted -s ${DISK} resizepart ${PART} 100%

From: https://openwrt.org/docs/guide-user/installation/openwrt_x86#resizing_partitions

But I got this error:

root@OpenWrt:~# parted -s ${DISK} resizepart ${PART} 100%
Error: Could not stat device /dev/mmcblk - No such file or directory.

What is wrong here actually? OpenWRT is running on my Raspberry Pi 3 Model B.

I actually need to enlarge my root directory. Currently:

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               102.3M     94.2M      6.1M  94% /
tmpfs                   458.9M      1.1M    457.8M   0% /tmp
/dev/mmcblk0p1           63.9M     18.3M     45.5M  29% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:~#

I cannot read the sed magic, but the result is clear. Your boot partition is /dev/mmcblk0p1, and the sed magic says the device is then /dev/mmcblk, which is wrong. The device is /dev/mmcblk0. So I think the command should be

parted -s /dev/mmcblk0 resizepart 2 100%
1 Like

But what I need is to resize the /dev/root to be able to install more packages/software. Can you please tell me what I really need to do to achieve this? I'm really a beginner in filesystems and partitions.

rather than resize the existing root partition on partition 1 you might want to reconsider creating a 2nd large partition on your remaining disk space and format using F2FS file system and extroot to the 2nd partition. I believe F2FS works better on nand flash than ext4 especially with regards to wear leveling and just leave the 1st partition as it is for booting. The only downside to this config is it's troublesome when updating firmware as you need to extroot after each firmware update.

Sounds fine to me. Can you add the commands to achieve this or any link?

Below link offers some ideas but in fact all the instructions for extroot is in LUCI itself. It should look something like this:

opkg install block-mount mount-utils
opkg install gdisk
opkg install f2fs-tools
opkg install kmod-fs-f2fs

gdisk /dev/mmcblk0
enter the following in gdisk:
n
w
y

the above should automatically create a 2nd partition using all remaining disk space assuming you only have one partition.

mkfs.f2fs /dev/mmcblk0p2 (assume mmcblk0p2 is 2nd partition)

  • or -

mkfs.f2fs -o 30 /dev/mmcblk0p2 (this provisions 30% for future bad nand)

open LUCI and go to mount points select your mmcblk0p2 and mount it to /

a message box will automatically appear. SSH into openwrt and follow the instructions. CAVEAT: the instructions assume SDA1 but your device is MMCBLK0P2 so enter each instruction separately and change SDA1 for MMCBLK0P2.

apply settings then reboot.

1 Like