SYSTEMD.MSTACK(7)
π SYSTEMD.MSTACK π
okay so bestie, we're talking about systemd.mstack β mount stacks, but make them self-descriptive. it's giving organized. it's giving main character. let's get into it π«Ά
β¨ NAME β¨
systemd.mstack β mount stacks living in self descriptive directories πΈ
π DESCRIPTION π
So. Directories with the .mstack/ suffix? They can encode 'mount stacks' for assembling OS mount hierarchies out of bind mounts and overlay mounts. Where do you use them? Two places, periodt:
systemd-nspawn(1)'s--mstack=switch- the service manager's
RootMStack=setting for services
A .mstack/ directory can hold all kinds of files and subdirectories, and each one effects one layer of an "overlayfs" mount, or a bind mount. The name of the file or subdirectory is what tells you how it gets used in the mount hierarchy. Specifically, these names are defined:
- A
layer@id/directory gets turned into a layer of an overlayfs mount. The"id"identifier defines the order of the layers: a version sort runs, the first entry is the bottom layer in the"overlayfs"stack, and the last entry becomes the highest layer β precisely, the highest"lowerdir"β in the"overlayfs"stack. π - Similar vibes: a
layer@id.rawregular file gets mounted as a DDI, and that resulting mount gets turned into an overlayfs layer, following the exact same sorting rules. - An
rwdirectory becomes a writable layer at the very top of the"overlayfs"stack. A subdirectorydataof it becomes the"upperdir", and a subdirectoryworkbecomes the"workdir". Heads up bestie: those two subdirectories do not need to be created explicitly β they get created automatically on first use if they're missing. no cap β¨ - A
bind@location/directory gets bind mounted to the mount point indicated by the location identifier, in read-write fashion. The location is encoded via the same escaping logic used for naming".mount"units, i.e. slashes become dashes. - Similar: a
bind@location.rawfile gets mounted as a DDI, and the resulting mount gets bind mounted to the specified location. - A
robind@location/is treated very similar tobind@location/, but the resulting bind mount is read-only. - Similar:
robind@location.rawcreates a read-only bind mount from a DDI. - If a
root/subdirectory exists, it's used as root of the resulting mount hierarchy, and only theusr/subtree of the overlayfs mount will be bound tousr/in the hierarchy.
π«Ά note note note: each of the entry types above may be a symbolic link pointing to a directory or image file, instead of a directory or image file itself. yes really.
On each listed file or subdirectory type, the systemd.v(7) functionality may be used β that's your automatic selection of versioned resources. iconic.
And to process or mount .mstack/ directories straight from the command line? Use the systemd-mstack(1) tool. π
π¦ EXAMPLES π¦
Example one: this .mstack/ consists of two read-only overlayfs layers as DDI, plus one writable directory on top. The read-only layers are symlinked:
foobar.mstack/layer@0.rawβ../base.rawfoobar.mstack/layer@1.rawβ../app.rawfoobar.mstack/rw/
Example two: this .mstack/ consists of a read-only DDI mounted to "/usr/" and a writable root:
waldo.mstack/layer@0.rawβ../vendor.rawwaldo.mstack/root/
Example three: this .mstack/ consists of a read-only DDI mounted as root, but a writable /var/ mounted on top:
quux.mstack/layer@0.rawβ../myapp1.rawquux.mstack/bind:varβ../myapp1-var/
β SEE ALSO β
systemd(1), systemd-mstack(1), systemd-nspawn(1), systemd.exec(5), systemd.v(7), systemd-vpick(1)
and that's the whole page bestie π this was systemd 262.1, SYSTEMD.MSTACK(7) β go build a mount stack, you're literally the moment ππ
π¦ where this page comes from
- arch rolling: systemd 262.1-1 Β· LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms