Mochabin-5G Expand OpenWrt Partition

After a lot of searching, I found the solution in this post:

With the permission of user happydashery, I am going to repeat his way extending the eMMC of the Mochabin to the full size:

Have a first look at the existing partitions:

root@OpenWrt:~# df -Th
Filesystem           Type            Size      Used Available Use% Mounted on
/dev/root            squashfs        3.5M      3.5M         0 100% /rom
tmpfs                tmpfs           3.9G      1.1M      3.9G   0% /tmp
/dev/loop0           f2fs           98.8M     61.5M     37.3M   62% /overlay
overlayfs:/overlay   overlay        98.8M     61.5M     37.3M   62% /
tmpfs                tmpfs         512.0K         0    512.0K   0% /dev

Especially look out for the partition /dev/loop0, which has the type f2fs.
There were posts in the past, that some users have seen there Ext4 as type.

Important: This guide only works on the eMMC with the /dev/loop0 partition running on F2FS.

Install these packages:

opkg update
opkg install losetup e2fsprogs resize2fs block-mount kmod-fs-f2fs f2fs-tools cfdisk kmod-fs-ext4 parted rsync

Confirm, that the device /dev/loop0 is located on the 2nd partition of mmcblk0 by checking the back file column:

root@OpenWrt:~# losetup
NAME       SIZELIMIT  OFFSET AUTOCLEAR RO BACK-FILE  DIO LOG-SEC
/dev/loop0         0 3604480         1  0 /mmcblk0p2   0     512

Resize the partition mmcblk0p2 by using cfdsik:

root@OpenWrt:~# cfdisk /dev/mmcblk0

Chose the 2nd partition,
Move the cursor to resize,
Enter the final size you want, default is 14.7GB.
Confirm the change by the menu entry "Write".

Set variables, that are used later:

LOOP="$(losetup -n -O NAME | sort | sed -n -e "1p")"
ROOT="$(losetup -n -O BACK-FILE ${LOOP} | sed -e "s|^|/dev|")"
OFFS="$(losetup -n -O OFFSET ${LOOP})"

Check the variables withe echo command:

root@OpenWrt:~# echo ${OFFS} ${LOOP} ${ROOT}
3604480 /dev/loop0 /dev/mmcblk0p2

The loop device setup:

LOOP="$(losetup -f)"
losetup -o ${OFFS} ${LOOP} ${ROOT}

Finalize the partition resize:

fsck.f2fs -f ${LOOP}  #and go for default options if given any
mount ${LOOP} /mnt
umount ${LOOP}
resize.f2fs ${LOOP}
reboot

This procedure was done by me two times, it's working and results in:

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 22.03.3, r20028-43d71ad93e
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~# df -Th
Filesystem           Type            Size      Used Available Use% Mounted on
/dev/root            squashfs        3.5M      3.5M         0 100% /rom
tmpfs                tmpfs           3.9G    240.0K      3.9G   0% /tmp
/dev/loop0           f2fs           14.7G    609.8M     14.1G   4% /overlay
overlayfs:/overlay   overlay        14.7G    609.8M     14.1G   4% /
tmpfs                tmpfs         512.0K         0    512.0K   0% /dev

LuCi confirms this:

Special thanks to user @happydashery.

1 Like