Resurrect factory images for Edgerouter-X?

For a very long time, factory images for Edgerouter-X have not been building as the size of the kernel+initramfs is bigger than the available 3MB kernel slot. For previous releases there have been custom builds made with very stripped down config that managed to squeeze into this space.

However its getting increasingly harder to fit. 23.05 will only fit if build without Luci. 24.x with linux 6.6 likely wont fit at all even with stripped down config.

However the Ubiquiti image format does allow to split out the rootfs into a separate file squashfs.tmp which gets written to the ubi0_0 volume. With this change 23.05 fits into factory without any custom config. 24.x may also fit with some tweaks.

The format of ubifs is shown in this post:

However I tried many different kernel cmdlines and cannot get the mainline kernel to mount this squashfs image as rootfs. I feel that the closest I got was this, which mounts the volume containing squashfs, but can't find anyway to mount the rootfs.

bootargs console=ttyS1,57600n8 ubi.mtd=4 ubi.block=0,0 root=/dev/ubiblock0_0

Is there anyway to get this to mount? Am i missing some config here? do any existing boards use a similar format? Or are Ubiquiti using custom code in their downstream kernel to support this format?

Ubiquiti bootargs:

bootargs console=ttyS1,57600n8 ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rootsqimg=squashfs.img rootsqwdir=w rw model=e50

root@OpenWrt:/# ubinfo -a
UBI version: 1
Count of UBI devices: 1
UBI control device major/minor: 10:127
Present UBI devices: ubi0

Volumes count: 1
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 1972 (250396672 bytes, 238.7 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 10
Count of reserved physical eraseblocks: 30
Current maximum erase counter value: 12
Minimum input/output unit size: 2048 bytes
Character device major/minor: 251:0
Present volumes: 0

Volume ID: 0 (on ubi0)
Type: dynamic
Alignment: 1
Size: 1938 LEBs (246079488 bytes, 234.6 MiB)
State: OK
Name: troot
Character device major/minor: 251:1

Contents of ubi0_0 (troot), squashfs.img here is openwrt rootfs:

root@OpenWrt:/tmp/mnt# ls -al
drwxr-xr-x 5 root root 784 Jan 1 2015 .
drwxrwxrwt 16 root root 420 Jan 1 00:01 ..
-rw-r--r-- 1 1000 1000 2659014 Apr 20 2024 squashfs.img
-rw-r--r-- 1 1000 1000 33 Apr 20 2024 squashfs.img.md5
-rw-r--r-- 1 root root 80646144 Jul 14 2019 squashfs.o
-rw-r--r-- 1 root root 33 Jul 14 2019 squashfs.o.md5
-rw-r--r-- 1 1000 1000 33 Apr 20 2024 version
-rw-r--r-- 1 root root 43 Jul 14 2019 version.o
drwxrwxr-x 4 root 102 288 Jan 1 2015 w
drwxr-xr-x 10 root root 824 Jan 1 2015 w.o
drwxr-xr-x 2 33 root 224 Jan 1 2015 www

OpenWrt does not support the use of rootfs binary, which exists within the other filesystem, but in stock firmware, it is probably achieved by rootsqimg=squashfs.img.
Using initramfs image for factory image is a workaround to bypass that restriction.

I drop the factory builds completely in that PR, but at same time, though I would check if there is any other option.

which would been fine, but we are long past those images fitting onto this device.

1 Like

It should be possible to loop mount the squashfs.img as a rootfs using a special purpose initramfs with only the required binaries and scripts for that.

yes I did think of this option by building a stripped down busybox initramfs , but not to sure how I would implement that within the openwrt build system.