Nbg6817 - Using all of router's space for OpenWrt root

I have a zyxel_nbg6817 which has a preposterous amount of on-board flash (4GB). However, after flashing OpenWRT and using for a few weeks my free space looks like:

Filesystem                Size      Used Available Use% Mounted on
/dev/root                 3.8M      3.8M         0 100% /rom
tmpfs                   234.6M     41.7M    192.9M  18% /tmp
/dev/loop0               54.5M     53.1M         0 100% /overlay
overlayfs:/overlay       54.5M     53.1M         0 100% /
tmpfs                   512.0K         0    512.0K   0% /dev

This seems to show that my root overlay has only 54.5MB available, even though the router has 4GB onboard! Poking around with block info:

/dev/loop0: UUID="76eded13-598e-4a6c-83bf-af251ad05661" LABEL="rootfs_data" VERSION="1.0" MOUNT="/overlay" TYPE="ext4"
/dev/mmcblk0p1: UUID="9461a4e9-d4e8-4a02-a0e4-03ce70563bac" VERSION="1.0" TYPE="ext4"
/dev/mmcblk0p10: UUID="9fb10f52-f329-45bb-9991-e463b0f399ba" VERSION="1.0" TYPE="ext4"
/dev/mmcblk0p5: UUID="def69b70-d94a134d-4dbc53f4-e3da1a4b" VERSION="4.0" TYPE="squashfs"
/dev/mmcblk0p8: UUID="bbb70c1d-81ca069a-611c1595-2ce359b2" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"

and with gdisk:

Disk /dev/mmcblk0: 7634944 sectors, 3.6 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20
Partition table holds up to 12 entries
Main partition table begins at sector 2 and ends at sector 4
First usable sector is 34, last usable sector is 7634910
Partitions will be aligned on 2-sector boundaries
Total free space is 1 sectors (512 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
1  34  8225   4.0 MiB     FFFF  rootfs_data
2  8226  16417   4.0 MiB     FFFF  romd
3  16418  18465   1024.0 KiB  FFFF  header
4  18466  26657   4.0 MiB     FFFF  kernel
5  26658  157729   64.0 MiB    FFFF  rootfs
6  157730  159777   1024.0 KiB  FFFF  header_1
7  159778  167969   4.0 MiB     FFFF  kernel_1
8  167970  299041   64.0 MiB    FFFF  rootfs_1
9  299042  823329   256.0 MiB   FFFF  bu1
10  823330  7634909   3.2 GiB     FFFF  bu2

So, that partition 10 has 3.2 GB! I mounted it, and it seems... basically empty. A few files on it, but mostly just free space:

# find
.
./Streamboost
./Streamboost/DataBaseBackup
./lost+found
./netprb_db_ver
./netprobe.db
# du -sh .
40.0K   .

How can I get this free space into my root? I see things around about "extroot" if I want to use a USB stick, but I don't really want to replace the overlap system, I think I just want one layer of the overlay to be a folder on this partition instead of whatever tiny partition it is using now?

you've contradicted (and answered) yourself...

I don't think I've answered myself, since I don't know how to do that :stuck_out_tongue:

extroot docs always seem to get rid of the overlay entirely and just mount root from outside. That doesn't seem necessary here, the squashfs is fine, and honestly even the 60MB partition is fine if I could have three layers (but I doubt overlayfs will let me get that fancy...) -- but I don't know where the configuration for what gets mounted at /overlay/... lives, since extroot docs just tell you to remove that instead of how to change it.

Also, the extroot docs smell wrong for this device in general, since:

sed -n -e "/\s\/overlay\s.*$/s///p" /etc/mtab prints /dev/loop0 which seems very unlikely to be the actual place the 60MB partition is mounted from?

You have two problems (and a third lingering, should you decide to go forward nevertheless):

  • the overlay is version specific by definition, you can't share one overlay for two firmware installations
  • potential reverting to stock, I don't know how the OEM firmware will cope without streamboost data (if that can be re-initialized)
  • if you still decide to go ahead, you will have to change the nbg6817 device support on the source level - and quite substantially at multiple layers. it means diverging from the (OpenWrt- and OEM-) defaults, with zero sysupgrade compatibility - you will have to keep building your custom OpenWrt(-fork) forever.

64 MB dedicated to the rootfs is already quite plenty, do you really need more than that?

1 Like

the overlay is version specific by definition, you can't share one overlay for two firmware installations

Not sure what this means. I only have one firmware, the OpenWRT install?

potential reverting to stock, I don't know how the OEM firmware will cope without streamboost data (if that can be re-initialized)

Are you saying the big partition is not empty even though it appears to be, but contains some invisible data? And that that data might be required if I ever stop using OpenWRT? So long as it won't break OpenWRT to lose any phantom data, I'm never going back to OEM. I bought the router specifically to run OpenWRT on it.

if you still decide to go ahead, you will have to change the nbg6817 device support on the source level - and quite substantially at multiple layers. it means diverging from the (OpenWrt- and OEM-) defaults, with zero sysupgrade compatibility - you will have to keep building your custom OpenWrt(-fork) forever.

Why? I just want to change one part of the OverlayFS to store in a different partition than currently. If the extroot instructions on the wiki didn't show me a loop device I could probably just use that without issue. I may be able to even so, or figure out what is behind that loop device (though if anyone knows and can tell me it would be a lot easier :slight_smile: ) -- shouldn't need to do anything so extreme as forking since extroot style setups are supported? Just this one isn't external so I felt there should be a simpler way since I don't need anything to happen when the partition is "removed" since it cannot be removed.

64 MB dedicated to the rootfs is already quite plenty, do you really need more than that?

64 MB is pretty small. I've filled it already in just two weeks, and I don't feel like I've installed that much software. I could poke around and free up some space (already uninstalled curl just to make room to play with still) but since the device has mountains of space sitting empty it seems odd to act like I have a tight budget when I don't need to...

Because of this:

squashfs

The root partition has always the same size to be able to reflash manufacturer firmware at any time (this is a design decission! the 64MiB is a fixed size fitting to your device).
In this partition is written a squashfs image file (read only; size will change with every update). The part which is left after writing squashfs is used as data partition (size will change accordingly with every upgrade). All in all it will never be larger then 64 MiB.

You would need to change this behaviour in installation/upgrade routine of OpenWrt and/or you have to change the definition of that what Overlayfs is in OpenWrt source. Exactly that what @slh has written already.

EDIT:
A possible approach would be using the 3,2 GiB partition as an extroot. You can format it (did that already in the past; but made an image before). Data will be rewritten from Zyxel firmware. But you will have all side-effects using an extroot.