systemd's mstack silently overwrites read-only files due to unclear writable-layer default
A developer testing systemd's new mstack tool — introduced in systemd 260 in March 2025 — found that mounting a single-layer directory made it writable by default, causing a read-only file to be permanently overwritten with no error or warning. The mstack feature simplifies overlayfs mounts by letting users describe layered directories with symlinks instead of lengthy mount commands, and gained broader support in systemd-nspawn with the June 2025 release of systemd 261. During testing inside a standard Docker container, mstack produced a cryptic error referencing an internal function called '(layerfd)' when attempting to stack overlayfs on top of Docker's own overlay2 filesystem — a long-standing Linux kernel restriction. The same operation using a hand-written mount command fails too, but with a clearer message about unsupported upper directories. The workaround is to place the mount layers on a non-overlayfs filesystem such as tmpfs or a bind-mounted host directory.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in