public inbox for yocto@lists.yoctoproject.org
 help / color / mirror / Atom feed
* overlayfs-etc on top of dm-verity?
@ 2026-03-25 21:20 Michael Opdenacker
  2026-03-26  9:56 ` Michael Opdenacker
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Opdenacker @ 2026-03-25 21:20 UTC (permalink / raw)
  To: Vyacheslav Yurkov; +Cc: michael.opdenacker, yocto

Hi Slava and community,

Do you know if overlayfs and in particular our overlayfs-etc class works 
when /etc is on a dm-verity root filesystem?

Without dm-verity (regular ext4 or erofs root filesystem), everything 
looks all right:
# mount | grep overlay
/data/overlay-etc/upper on /etc type overlay 
(rw,relatime,lowerdir=/etc,upperdir=/data/overlay-etc/upper,workdir=/data/overlay-etc/work,uuid=on)

When /etc is on /dev/mapper/rootfs (dm-verity), everything seems messed up:
# mount | grep overlay
overlay on /var/cache type overlay 
(rw,relatime,lowerdir=/var/cache,upperdir=/var/volatile/cache,workdir=/var/volatile/.cache-work,uuid=on)
overlay on /var/lib type overlay 
(rw,relatime,lowerdir=/var/lib,upperdir=/var/volatile/lib,workdir=/var/volatile/.lib-work,uuid=on)
overlay on /var/spool type overlay 
(rw,relatime,lowerdir=/var/spool,upperdir=/var/volatile/spool,workdir=/var/volatile/.spool-work,uuid=on)
overlay on /srv type overlay 
(rw,relatime,lowerdir=/srv,upperdir=/var/volatile/srv,workdir=/var/volatile/.srv-work,uuid=on)

Systemd may be messing up, as only in this case, it does:
          Starting Bind mount volatile /var/cache...
          Starting Bind mount volatile /var/lib...
          Starting Bind mount volatile /var/spool...
          Starting Bind mount volatile /srv...

But these bind mounts show up as overlay mounts!

Has anyone already encountered such an issue?
Thanks in advance,
Cheers
Michael.

-- 
Root Commit
Embedded Linux Training and Consulting
https://rootcommit.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: overlayfs-etc on top of dm-verity?
  2026-03-25 21:20 overlayfs-etc on top of dm-verity? Michael Opdenacker
@ 2026-03-26  9:56 ` Michael Opdenacker
  2026-03-26 17:41   ` Michael Opdenacker
  2026-03-26 22:19   ` [yocto] " Francesco Valla
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Opdenacker @ 2026-03-26  9:56 UTC (permalink / raw)
  To: Vyacheslav Yurkov; +Cc: michael.opdenacker, yocto

Greetings,

On 3/25/26 10:20 PM, Michael Opdenacker wrote:
> Hi Slava and community,
>
> Do you know if overlayfs and in particular our overlayfs-etc class 
> works when /etc is on a dm-verity root filesystem?
>
> Without dm-verity (regular ext4 or erofs root filesystem), everything 
> looks all right:
> # mount | grep overlay
> /data/overlay-etc/upper on /etc type overlay 
> (rw,relatime,lowerdir=/etc,upperdir=/data/overlay-etc/upper,workdir=/data/overlay-etc/work,uuid=on)
>
> When /etc is on /dev/mapper/rootfs (dm-verity), everything seems 
> messed up:
> # mount | grep overlay
> overlay on /var/cache type overlay 
> (rw,relatime,lowerdir=/var/cache,upperdir=/var/volatile/cache,workdir=/var/volatile/.cache-work,uuid=on)
> overlay on /var/lib type overlay 
> (rw,relatime,lowerdir=/var/lib,upperdir=/var/volatile/lib,workdir=/var/volatile/.lib-work,uuid=on)
> overlay on /var/spool type overlay 
> (rw,relatime,lowerdir=/var/spool,upperdir=/var/volatile/spool,workdir=/var/volatile/.spool-work,uuid=on)
> overlay on /srv type overlay 
> (rw,relatime,lowerdir=/srv,upperdir=/var/volatile/srv,workdir=/var/volatile/.srv-work,uuid=on)
>
> Systemd may be messing up, as only in this case, it does:
>          Starting Bind mount volatile /var/cache...
>          Starting Bind mount volatile /var/lib...
>          Starting Bind mount volatile /var/spool...
>          Starting Bind mount volatile /srv...
>
> But these bind mounts show up as overlay mounts!
>
> Has anyone already encountered such an issue?

I eventually managed to get /etc mounted as an overlay. It seems that 
/sbin/init was started instead of /sbin/preinit as specified in the 
kernel command line.
I hardcoded the call to /sbin/preinit by customizing 
openembedded-core/meta/recipes-core/initrdscripts/initramfs-framework/finish 
(in a bbappend file, of course).

The code looks right though, I need to understand why this happens.

Another weirdness that remains is these volatile mounts for /var/cache/, 
/var/lib, /var/spool and /srv, which I didn't have with a regular 
read-only root filesystem.
I'll keep you posted.
Cheers
Michael.

-- 
Root Commit
Embedded Linux Training and Consulting
https://rootcommit.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: overlayfs-etc on top of dm-verity?
  2026-03-26  9:56 ` Michael Opdenacker
@ 2026-03-26 17:41   ` Michael Opdenacker
  2026-03-26 22:19   ` [yocto] " Francesco Valla
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Opdenacker @ 2026-03-26 17:41 UTC (permalink / raw)
  To: Vyacheslav Yurkov; +Cc: michael.opdenacker, yocto

Greetings,

So follow-up on this issue...

On 3/26/26 10:56 AM, Michael Opdenacker wrote:
>
>
> On 3/25/26 10:20 PM, Michael Opdenacker wrote:
>
> I eventually managed to get /etc mounted as an overlay. It seems that 
> /sbin/init was started instead of /sbin/preinit as specified in the 
> kernel command line.
> I hardcoded the call to /sbin/preinit by customizing 
> openembedded-core/meta/recipes-core/initrdscripts/initramfs-framework/finish 
> (in a bbappend file, of course).
>
> The code looks right though, I need to understand why this happens.


The issue (the initramfs scripts not calling the init script specified 
in the kernel command line) was caused by an issue with kernel 
parameters like:
opt="value", that happen when you use the kernel's "bootconfig" 
configuration options.

This fix I've just submitted solves the issue: 
https://lore.kernel.org/openembedded-core/20260326173432.3286250-1-michael.opdenacker@rootcommit.com/T/#u

Cheers
Michael.

Root Commit
Embedded Linux Training and Consulting
https://rootcommit.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [yocto] overlayfs-etc on top of dm-verity?
  2026-03-26  9:56 ` Michael Opdenacker
  2026-03-26 17:41   ` Michael Opdenacker
@ 2026-03-26 22:19   ` Francesco Valla
  2026-04-09 19:18     ` Michael Opdenacker
  1 sibling, 1 reply; 5+ messages in thread
From: Francesco Valla @ 2026-03-26 22:19 UTC (permalink / raw)
  To: michael.opdenacker; +Cc: yocto, Vyacheslav Yurkov

Hi Michael,

On Thu, Mar 26, 2026 at 09:56:21AM +0000, Michael Opdenacker via lists.yoctoproject.org wrote:
> Greetings,
> 
> On 3/25/26 10:20 PM, Michael Opdenacker wrote:
> > Hi Slava and community,
> > 
> > Do you know if overlayfs and in particular our overlayfs-etc class works
> > when /etc is on a dm-verity root filesystem?
> > 
> > Without dm-verity (regular ext4 or erofs root filesystem), everything
> > looks all right:
> > # mount | grep overlay
> > /data/overlay-etc/upper on /etc type overlay (rw,relatime,lowerdir=/etc,upperdir=/data/overlay-etc/upper,workdir=/data/overlay-etc/work,uuid=on)
> > 
> > When /etc is on /dev/mapper/rootfs (dm-verity), everything seems messed
> > up:
> > # mount | grep overlay
> > overlay on /var/cache type overlay (rw,relatime,lowerdir=/var/cache,upperdir=/var/volatile/cache,workdir=/var/volatile/.cache-work,uuid=on)
> > overlay on /var/lib type overlay (rw,relatime,lowerdir=/var/lib,upperdir=/var/volatile/lib,workdir=/var/volatile/.lib-work,uuid=on)
> > overlay on /var/spool type overlay (rw,relatime,lowerdir=/var/spool,upperdir=/var/volatile/spool,workdir=/var/volatile/.spool-work,uuid=on)
> > overlay on /srv type overlay (rw,relatime,lowerdir=/srv,upperdir=/var/volatile/srv,workdir=/var/volatile/.srv-work,uuid=on)
> > 
> > Systemd may be messing up, as only in this case, it does:
> > � � � � �Starting Bind mount volatile /var/cache...
> > � � � � �Starting Bind mount volatile /var/lib...
> > � � � � �Starting Bind mount volatile /var/spool...
> > � � � � �Starting Bind mount volatile /srv...
> > 
> > But these bind mounts show up as overlay mounts!
> > 
> > Has anyone already encountered such an issue?
> 
> I eventually managed to get /etc mounted as an overlay. It seems that
> /sbin/init was started instead of /sbin/preinit as specified in the kernel
> command line.
> I hardcoded the call to /sbin/preinit by customizing
> openembedded-core/meta/recipes-core/initrdscripts/initramfs-framework/finish
> (in a bbappend file, of course).
> 
> The code looks right though, I need to understand why this happens.
> 
> Another weirdness that remains is these volatile mounts for /var/cache/,
> /var/lib, /var/spool and /srv, which I didn't have with a regular read-only
> root filesystem.

AFAIK, this should be the regular behavior on a read-only root
filesystem. The overlayfs mounts are created by services generated by:

  meta/recipes-core/volatile-binds/volatile-binds.bb

depending on the content of the VOLATILE_BINDS variable. For each couple
of upperdir-lowerdir specified there, a service is generated that
starts only if upperdir's parent is writable and lowerdir is not.

E.g.:
  lowerdir=/srv
  upperdir=/var/volatile/srv

In a vanilla openembedded-core system, a tmpfs is mounted on /var/volatile
by the fstab (that is, by the fstab systemd generator), so the
upperdir's parent directory (which is the same /var/volatile) is writable.

You can force a copy+bind behavior setting AVOID_OVERLAYFS=1.

> I'll keep you posted.
> Cheers
> Michael.
> 
> -- 
> Root Commit
> Embedded Linux Training and Consulting
> https://rootcommit.com
> 

Best regards,
Francesco



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [yocto] overlayfs-etc on top of dm-verity?
  2026-03-26 22:19   ` [yocto] " Francesco Valla
@ 2026-04-09 19:18     ` Michael Opdenacker
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Opdenacker @ 2026-04-09 19:18 UTC (permalink / raw)
  To: Francesco Valla; +Cc: michael.opdenacker, yocto, Vyacheslav Yurkov

Hi Francesco,

On 3/26/26 11:19 PM, Francesco Valla wrote:
>> The code looks right though, I need to understand why this happens.
>>
>> Another weirdness that remains is these volatile mounts for /var/cache/,
>> /var/lib, /var/spool and /srv, which I didn't have with a regular read-only
>> root filesystem.
> AFAIK, this should be the regular behavior on a read-only root
> filesystem. The overlayfs mounts are created by services generated by:
>
>    meta/recipes-core/volatile-binds/volatile-binds.bb
>
> depending on the content of the VOLATILE_BINDS variable. For each couple
> of upperdir-lowerdir specified there, a service is generated that
> starts only if upperdir's parent is writable and lowerdir is not.
>
> E.g.:
>    lowerdir=/srv
>    upperdir=/var/volatile/srv
>
> In a vanilla openembedded-core system, a tmpfs is mounted on /var/volatile
> by the fstab (that is, by the fstab systemd generator), so the
> upperdir's parent directory (which is the same /var/volatile) is writable.
>
> You can force a copy+bind behavior setting AVOID_OVERLAYFS=1.

I didn't thank you for these great clarifications and tips. It's good to 
understand the "magic".
I eventually dropped overlayfs-etc and started implementing specific 
mount points using VOLATILE_BINDS indeed (with AVOID_OVERLAYFS=1).

It's a very easy to use mechanism thanks to the volatile-binds.bb recipe.
Thanks again, you made my day!
Cheers
Michael.

-- 
Root Commit
Embedded Linux Training and Consulting
https://rootcommit.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-09 19:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 21:20 overlayfs-etc on top of dm-verity? Michael Opdenacker
2026-03-26  9:56 ` Michael Opdenacker
2026-03-26 17:41   ` Michael Opdenacker
2026-03-26 22:19   ` [yocto] " Francesco Valla
2026-04-09 19:18     ` Michael Opdenacker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox