Best pratices to create a read-only minimal system with a partition read-write

I want to create a read-only image (core-image-minimal) with a read-write partition. How to proceed? What is the best practice?

I’m using systemd.


Please note that BSP V2.4 is no longer supported on Colibri iMX6.

The Yocto/OpenEmbedded build system has capabilities to build a rootfs ment to be mounted read-only:

As the chapter states, the challenge is that all the packages you are using have a post-installation step which can run “offline” (during root filesystem creation)…

The easiest way is probably just trying it out and see what/if something fails. As @marcel.tx notes, the 2.4 release is rather old. The above link to the Yocto developer manual is for the Yocto 2.0, which aligns with our V2.6 release.

I’ve done this on the Apalis T30 platform. First, there should be 2 partitions on the disk, one for the read-only OS/kernel/Device tree, and one for the user data. In our case, we used FAT32 to store a tezi u-boot FIT image plus boot script as per u-boot-distro-boot and ext3 for data partition. If it doesn’t need to be read/write by a windows machine, then there are far better options than FAT32 for data integrity. I’ll leave it to you to research the other file system types. Some are better for data integrity/performance/write vs read performance/faster disk check routine.

With core-image-minimal compiled as poky-tiny, the file system is around 500k, plus kernel and device tree to around 5MB. It can quickly grow if you start adding stuff though. The kernel is built to use initramfs. In this way, we load the image from disk read-only, but we don’t mind it being read/write in ram, as the OS can’t be corrupted due to power loss.

As for data partition, you probably want one of the flash safe(r) file systems like JFFS2, UBIFS etc. Something that has data checking and a fast disk check on bootup. A slow disk check will slow system boot time.

HI @kswain

Thanks for your input.

Best regards,