Accessing a data partiton on the 8 GB of eMMC on GL.iNET Flint 2 (GL-MT6000)

It seems that the entire usable amount of flash memory is devoted to the overlay mount:

# df -h
Filesystem          Size  Used Avail Use% Mounted on
/dev/root            12M   12M     0 100% /rom
tmpfs               462M  264K  462M   1% /tmp
/dev/loop0          7.3G  191M  7.1G   3% /overlay
overlayfs:/overlay  7.3G  191M  7.1G   3% /
tmpfs               512K     0  512K   0% /dev

How can I create a data partition on my MT6000's 8 GB eMMC flash memory? My use case of OpenWrt will not require more than a few hundred MB of system partition. To keep things sane, let's say 512 MB. I'd like to partition the remaining 7+ GB of the eMMC for data, formatted to ext4. How can I accomplish this?

If this were x86, I think setting the following in my .config would do it, but I want to be 100% certain:


I do not know if that is right since my x86 box uses the ext4 profile which might be different than the one for this device.

@_FailSafe - you happen to be doing this?

I'm not doing anything with this at this point. Haven't had the need given I'm just using these as WAPs. But I'm curious how this plays out!

# fdisk -l
Disk /dev/loop0: 7.23 GiB, 7758151680 bytes, 15152640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
The backup GPT table is not on the end of the device.

Disk /dev/mmcblk0: 7.28 GiB, 7818182656 bytes, 15269888 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 2BD17853-102B-4500-AA1A-8A21D4D7984D

Device         Start      End  Sectors  Size Type
/dev/mmcblk0p1  8192     9215     1024  512K Linux filesystem
/dev/mmcblk0p2  9216    13311     4096    2M Linux filesystem
/dev/mmcblk0p3 13312    17407     4096    2M Linux filesystem
/dev/mmcblk0p4 17408    21503     4096    2M Linux filesystem
/dev/mmcblk0p5 21504    25599     4096    2M Linux filesystem
/dev/mmcblk0p6 25600    91135    65536   32M Linux filesystem
/dev/mmcblk0p7 91136 15269887 15178752  7.2G Linux filesystem

Disk /dev/mmcblk0boot0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mmcblk0boot1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Something is defining the partition scheme and to have p7 use 7.2G. I am wondering about modifying a hard-coded value somewhere to have it use only 0.5 G. Then I could manually partition the rest....

Question is what is defining that 7.2G p7 and can it be modified to a smaller value?

EDIT: was it set by the original GL.inet installer? If so, what is a safe method to resize it down to 0.5G and have that change remain as I flash new images moving forward?

You can modify the function rootdisk_create_loop in fstools.

info.lo_offset = p->offset;
info.lo_flags |= LO_FLAGS_AUTOCLEAR;
info.lo_sizelimit = ?

Add lo_sizelimit.

1 Like

Would something like F2FS not be more suited for a data partition on flash, like Android phones do?

EDIT: I see, you're recommending to modify libfstools/rootdisk.c of

What are the units of the number I should enter there? Is it bytes?

512 MiB = 536,870,900

iff --git a/libfstools/rootdisk.c b/libfstools/rootdisk.c
index ba7d8c3..e6ef613 100644
--- a/libfstools/rootdisk.c
+++ b/libfstools/rootdisk.c
@@ -183,6 +183,7 @@ static int rootdisk_create_loop(struct rootdev_volume *p)
                info.lo_offset = p->offset;
                info.lo_flags |= LO_FLAGS_AUTOCLEAR;
+               info.lo_sizelimit = 536870900
                if (ioctl(fd, LOOP_SET_STATUS64, &info) != 0) {
                        ioctl(fd, LOOP_CLR_FD, 0);

I have always used ext4 given how stable and robust it is. F2FS might be a good option too.

512*1024*1024 is 536870912 MiB (mebibytes).

But does the code expect bytes?

That is a good question, I don't find lo_sizelimit anywhere in the fstools code itself. It all depends on how the code treats it, but even then, it won't be as bytes. C can read this as an integer, as hex, as octal e.g., but it has no data type for bytes.

Please delete F2FS from collective memory, it's crap in all capital letters - its filesystem overhead is massive.

# mount | grep loop.*overlay
/dev/loop0 on /overlay type f2fs (rw,lazytime,noatime,background_gc=on,nodiscard,no_heap,user_xattr,inline_xattr,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,alloc_mode=reuse,checkpoint_merge,fsync_mode=posix,discard_unit=block,memory=normal)
# gdisk -l /dev/sda | grep ^\ \ \ 2
   2           66048         1950207   920.0 MiB   8300
# df -h /overlay/
Filesystem                Size      Used Available Use% Mounted on
/dev/loop0              891.3M     67.6M    823.7M   8% /overlay
# du -hs /overlay/
138.0K  /overlay/

So 138 KB of files on the overlay, 67.6 MB lost to f2fs filesystem overhead (and that's in addition to the 29 MB f2fs already reserved for the fs structures ahead of time, the raw partition is 920 MB in size) - and yes, that isn't much less for the default 104 MB image sizes (leaving you with very little free flash to play with).

This fs really is garbage.


Coming from here: GL.iNET Flint 2 (GL-MT6000) discussions - #1109 by SebTM

I'm not sure what's the proposed solution is and if I'm able to use it:

Create a custom image with ext4 and lower root-fs size - but do I need/still need to patch "rootdisk_create_loop" or is/will this be up-streamed?

Given the lack of replies, I will speculate that no one is bold enough to try it, and that all of us have massive root partitions going unused.

I’m thinking about this too.
Wouldn’t try on my main router though :smile:
At least not yet, as I’m still learning OpenWrt.

I'm also interested in changing the partition layout - but I'm unsure where to start.
Anyone had any success?