Adding swap support (for zram) to kernel for ath79 "tiny" targets

I've been working on extending life to a 4/32 "tiny" target, the TL-WR703N, by taking advantage of its USB port. Despite it being very resource-constrained, I actually have good use for an extremely small, low-power device like this (so no need for "buy something else" comments).

I've gotten 23.05.5 working on the TL-WR703N using a custom image with USB support made with Image Builder. I would like to be able to experiment with zram, but if my understanding is correct, zram depends on swap, and swap was disabled for the "tiny" targets to save space. When I install zram via luci, I get the error:

zram_start: kernel doesn't support swap

Likewise if I run swapon -s via ssh, I get:

block: failed to open /proc/swaps

Am I correct in thinking that the only way to enable swap support in the kernel is to build an image from source with swap enabled?

If so, given that support for "tiny" targets is over anyway, and assuming that enabling swap adds a minimal amount of increased size to the kernel (curious how much it actually adds but I'm assuming a few KBs at most), wouldn't it make more sense to re-enable it in the kernel by default, knowing that anyone like me wanting to run newer OpenWRT versions are going to have to use some form of external storage anyway? It seems silly to have to build from source just to enable this.

If not here, where's the proper place to make such a request?

1 Like

Correct.

That is not likely to happen.

2 Likes

Probably you need to limit zram compression to just one method, each is few to five kB-s

I don't see how to only install one method using menuconfig (you can select the default method), but regardless, it shouldn't be an issue, as kmod-zram and anything else can be installed to USB after initial setup. With 23.05.x and 4 MB flash, it's basically stripping everything out (no luci, no Wi-Fi drivers, no firewall, no dnsmasq, etc.), then adding block-mount, kmod-usb-storage and kmod-fs-f2fs to get access to USB storage. Once root is switched to a USB partition, space isn't an issue (but RAM still can be, of course).

To anyone: if building from source is the only way, and I want to create an Image Builder just like the one found in the 23.05.5 releases for ath79 tiny, I should use the config.buildinfo file from the releases downloads as my .config, then use make menuconfig and enable "Support for paging of anonymous memory (swap)", save without making any other changes and build?

If the resulting image size is not 8MB then your assumption is correct....