I have a pretty stable OpenWrt setup and want the changes that I do using various scripts to NOT be written to flash. (I do a lot of config changes and fear that they might wear out the flash)
Is there a way I can prevent the overlayFS from syncing with the disk? Basically, preventing disk writes all together?
You can use a initram image that has its rootfs as a ramdisk that doesn't use any write cycles of your flash.
You can flash this images like the sysupgrade image om most targets.
Thanks @juppin. I get the idea: these are special images that don't write to disk and run completely out of RAM.
Can I build these using the image builder? I would want the initram image to include my config and scripts otherwise I would have to configure it again after every boot.
In a build from source as well as Image Builder you can put any configs or other non-default files in the files/ tree under the buildroot. It does not exist by default, but will work if you add it.
For applications that are configured via uci, you can issue the uci commands as usual, but leave out the final uci commit. The new config can still be activated with reload_config or by restarting the affected service, but is not written to flash.
For non-uci applications, you can move the config file to /tmp and replace it with a symlink to the new location. Configuration updates go to /tmp, which is located in RAM.
Rebooting the device must somehow create an initial config. This could be done with an init script.
I use this approach on my RPi, but there I have access to a screen in case anything goes wrong. I was a bit skeptical to use this on my router since I wanted to avoid the risk of losing access.
I also thought that since OpenWrt uses an /overlay, there might be some way to prevent it from syncing to disk. Apparently, not an option though. Nevertheless, thanks for mentioning this, would be a helpful reference for for people with similar constraints trying to find a solution in the future