A tool to build squashfs image with separated /overlay partition

On some devices which have easy direct access to its storage devices like x86 and single board computers, it is better to have a separate partition for /overlay when running on squashfs /rom. Because they usually don’t have limitations for storage space. This can help combine the ease of squashfs and easy to manage.

My suggestion is to have a fixed partition like 64MiB to only store the squashfs /rom, and plus an additional ext4/f2fs partition behind to store /overlay.

This can also reduce the risk of losing data when using sysupgrade, which reduces time to deal with those serial of problems(restoring config/data etc.), as this will keep the /overlay partition in position with the same image building config.

1 Like

That stands true for (router-like) squashfs images.

Yes, this will help prevent the complexity for these devices.

I find out that a OpenWrt fork called iStoreOS is using a separate partition for /overlay.

More accurately they only ship squashfs images even for huge storage platforms.

I have written a script to deal with this situation, but it need block-mount to be included in the image and specific /etc/config/fstab config in the repo used. Image builder is necessary for this requirements (firmware-selector does not allow custom files).

This test well with my x86_64, RPi 4B, NanoPi R2S, ppl interested in can help me test out more single board computers. Include correct mounting and sysupgrade with -c and -o option

https://github.com/CreeperKong/openwrt-overlay-separator/

Remember to build your own squashfs image and run this script every time you need sysupgrade.

Overview

I have tested with my x86_64, RPi 4B, NanoPi R2S, it may work on other single board computers. Do not use for devices which have limited storage like retail routers.

Features

  1. Separated /overlay partition, enables easier management
  2. Keep /overlay partition stay at exact place, reduces the risk of data loss during sysupgrade
  3. /rom partition will probably stay at the same size when same set of included package is selected

How to use

  1. Use Image Builder to build squashfs images including block-mount and preconfigured /etc/config/fstab
  2. Patch the image by the tool
  3. Flash onto the storage device of target, or do sysupgrade

Note

Build custom squashfs image with the exact set of package and run this script every time when sysupgrade is needed.