* [pve-devel] [PATCH container] lxc config: mount /dev/shm tmpfs for application containers
@ 2025-12-02 15:27 Filip Schauer
0 siblings, 0 replies; only message in thread
From: Filip Schauer @ 2025-12-02 15:27 UTC (permalink / raw)
To: pve-devel
Mount a tmpfs at /dev/shm into containers without an init system which
would normally set up a shared memory filesystem. This satisfies the OCI
Runtime Spec [0], which specifies that the following should be made
available in the container:
/proc proc
/sys sysfs
/dev/pts devpts
/dev/shm tmpfs
The reason the mount is added conditionally is to avoid interfering with
init systems: systemd correctly detects an existing /dev/shm, but OpenRC
mounts it even if already present, resulting in duplicate mounts.
[0] https://github.com/opencontainers/runtime-spec/blob/fd25dd34a06b/config-linux.md#default-filesystems
Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
src/PVE/LXC.pm | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index de54a0d..e5ff3a1 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -756,6 +756,11 @@ sub update_lxc_config {
$raw .= "lxc.mount.auto = sys:mixed\n";
}
+ if (defined($conf->{entrypoint}) && $conf->{entrypoint} ne '/sbin/init') {
+ # Mount /dev/shm tmpfs into the container, if no init system runs to set it up.
+ $raw .= "lxc.mount.entry = shm dev/shm tmpfs rw,nosuid,nodev,create=dir 0 0\n";
+ }
+
PVE::LXC::Config->foreach_passthrough_device(
$conf,
sub {
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-02 15:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-02 15:27 [pve-devel] [PATCH container] lxc config: mount /dev/shm tmpfs for application containers Filip Schauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox