Mochabin-5G Expand OpenWrt Partition


I have reseted my OpenWRT based Mochabin router and it has 16GB of eMMC internal storage. Plenty for packages.

root@OpenWrt:~# lsblk
loop0          7:0    0 14.7G  0 loop /overlay
sda            8:0    1  3.7T  0 disk 
├─sda1         8:1    1   16M  0 part 
└─sda2         8:2    1  3.7T  0 part 
mtdblock0     31:0    0  3.9M  1 disk 
mtdblock1     31:1    0   64K  1 disk 
mtdblock2     31:2    0   64K  0 disk 
mmcblk0      179:0    0 14.7G  0 disk 
├─mmcblk0p1  179:1    0 16.3M  0 part 
└─mmcblk0p2  179:2    0 14.7G  0 part /rom
mmcblk0boot0 179:8    0    4M  1 disk 
mmcblk0boot1 179:16   0    4M  1 disk 

I would like to have OpenWRT using these 16GB of mmcblk0 fully, but when opening LuCi the status page says, that I am only having 98.81 MB, which are used with 60.91 MB.

Can I get a hint how to extend? I have only seen the x86 guide.

Well, that did not work out, probably by a mistake I have done.
Actually the device isn't now reachable anymore, it does not seem to boot up (correctly) anymore.

Recovering the device by holding the reset button, does not bring the device back.

Any idea how to proceed?

The device is re-initialized using this guide:

I have followed the instruction set using the cfdisk command, unfortunately, the procedure breaks at the resizef2fs command:

root@OpenWrt:~# resize2fs /dev/loop0
resize2fs 1.46.5 (30-Dec-2021)
resize2fs: Bad magic number in super-block while trying to open /dev/loop0
Couldn't find valid filesystem superblock.
root@OpenWrt:~# resize2fs /dev/mmcblk0
resize2fs 1.46.5 (30-Dec-2021)
resize2fs: Resource busy while trying to open /dev/mmcblk0
Couldn't find valid filesystem superblock.

I am going to restore the initial setup now.

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
/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}

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.

Hi Matthias

Thank you for the mention, you've made it much tidier than I did. I just wondered about running the initial df -h with T at the start of the process. You've got it at the end which is nice, but if it's done at the start it'll highlight if someone's got their overlay on ext4 which will mean they just need to use the 2 slightly different commands at the end. One of my plans is to use docker as well but that's something I've never touched before so will likely be asking you some questions about that. I'm thinking about putting Home assistant in a docker, so will have to see how that goes.

If I get time as well I'd still like to get the extending overlay stuff on the Mochabin device page. Unless someone else gets there first are you ok if I now copy most of your tidier guidance? I've taken some screenshots of the cfdisk stuff as well to add. Do you know if we have to get permission to add stuff to the device page?



Thanks for pointing out the filesystem type in the 1st section, I adopted your proposal.

Unfortunately, I cannot edit the wiki page, but that‘s the place for documenting this information.

Concerning docker:
That‘s the next part for me. I want to run Portainer on the device and inside Portainer, I setup stacks. One is for Smarthome stuff, especially 1st time running HomeAssistant in my local appliance.
If got the HomeAssistant SkyConnect USB stick, which includes ZigBee as well and is intended to run in Thread / Matter. Currently, the supporting HA software version is still in Beta, so I got little time to get prepared.
Next to that, I have installed a 4TB SSD to have enough space.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.