From c7bd5a3576f7449040e2164b6740c94cc2f5940c Mon Sep 17 00:00:00 2001 From: Vishwas Udupa Date: Wed, 17 Sep 2025 03:56:09 -0700 Subject: [PATCH] Enable systemd to create /var/lib/lxc at runtime with StateDirectory MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This change adds the StateDirectory= directive in the systemd unit file to ensure that the /var/lib/lxc directory is automatically created and managed by systemd during service startup. The StateDirectory= option instructs systemd to create a persistent state directory under /var/lib/. This is particularly useful in scenarios where the directory may be missing at first boot — such as on OSTree-based Linux distributions, which typically ship with empty /var directory as part of their immutable root filesystem. By adding StateDirectory=lxc, systemd will handle the creation of /var/lib/lxc on first boot, ensuring that the service can start reliably even when the directory is not present initially. Signed-off-by: Vishwas Udupa Co-developed-by: Raghuvarya S --- config/init/systemd/lxc.service.in | 1 + config/init/systemd/lxc@.service.in | 1 + 2 files changed, 2 insertions(+) diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in index 397a6c4d0..714265617 100644 --- a/config/init/systemd/lxc.service.in +++ b/config/init/systemd/lxc.service.in @@ -13,6 +13,7 @@ ExecStop=@LIBEXECDIR@/lxc/lxc-containers stop ExecReload=@LIBEXECDIR@/lxc/lxc-apparmor-load # Environment=BOOTUP=serial # Environment=CONSOLETYPE=serial +StateDirectory=lxc Delegate=yes [Install] diff --git a/config/init/systemd/lxc@.service.in b/config/init/systemd/lxc@.service.in index 21ce64aef..44e5b14dd 100644 --- a/config/init/systemd/lxc@.service.in +++ b/config/init/systemd/lxc@.service.in @@ -13,6 +13,7 @@ ExecStart=@BINDIR@/lxc-start -F -n %i ExecStop=@BINDIR@/lxc-stop -n %i # Environment=BOOTUP=serial # Environment=CONSOLETYPE=serial +StateDirectory=lxc Delegate=yes [Install] -- 2.47.3