How to create a writable read only file system for i.MX8MP on Mallow using Yocto

Hi Team,

I’m working on a Verdin iMX8M Plus with the Mallow carrier board, using the Scarthgap version of Yocto. I’m building the tdx-reference-multimedia-image, and I’d like to make the root filesystem effectively read-only but still writable during runtime. The goal is to have any changes made at runtime (logs, configs, temp files, etc.) stored in RAM and automatically discarded on reboot.

Could you please guide me on how to implement this in Yocto? Is there a recommended method for mounting the filesystem to support this behavior? Also, are there any existing recipes or layers I should include to enable this?
Would appreciate any guidance or suggestions.

Thanks.

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello,

Thank you for your question!

For your goal of having a root filesystem that appears writable at runtime (for logs, configs, temporary files, etc.) but discards all changes upon reboot, you essentially want to run with a read-only root filesystem while layering writable tmpfs (RAM-based) overlays for volatile directories.

There are a few important considerations:

1. Image Selection

The tdx-reference-multimedia-image is not recommended for read-only root filesystems due to its multimedia features and requirements (reference). Instead, the tdx-reference-minimal-image is better suited for this use case. However, if you need multimedia features, you would need to customize the image and address conflicts yourself.

2. Setting Read-Only RootFS in Yocto

To enable a read-only root filesystem, add the following to your conf/local.conf:

EXTRA_IMAGE_FEATURES += "read-only-rootfs"

This sets the root filesystem to read-only at boot time (reference).

3. Handling Volatile Data with tmpfs

Directories that need to be writable (such as /var, /tmp, /run) are typically mounted as tmpfs, so all changes go into RAM and are lost on reboot. The read-only-rootfs feature enables these mounts by default with appropriate settings in /etc/fstab like:

tmpfs  /run           tmpfs  mode=0755,nodev,nosuid,strictatime  0  0
tmpfs  /var/volatile  tmpfs  defaults                           0  0

Any run-time file written into /var/volatile, /run, etc., will be discarded on reboot (reference).

4. Overlays (Optional, Advanced)

Optionally, you can implement an overlay (such as OverlayFS) on the root filesystem, so the entire root appears writable, but all writes are ephemeral and lost after a reboot. Setting up OverlayFS root can be more complicated and may require custom Yocto recipes or init scripts.

5. Possible Issues (Multimedia Image)

Since you are using the multimedia image, some default packages (like alsa-state) might try to write to the root filesystem even after it’s set as read-only, which can cause issues. On Verdin SoMs, you should disable alsa-state package hooks with a bbappend in your custom Yocto layer:

pkg_postinst_ontarget:${PN}:mx8m-generic-bsp:tdx () {
}

(reference)

6. Torizon OS (Alternative)

If you are open to alternatives, Torizon OS provides a read-only root filesystem by default together with container-based workflows—making your use case of discarding changes on reboot essentially the default behavior (reference).


For more details and step-by-step instructions, please see the official guide:

Let me know if you need specific examples on how to adapt this setup to your multimedia image, or have further questions!

Best regards,
Toradex AI Assistant.