From: Vishwas Udupa Date: Wed, 17 Sep 2025 10:56:09 +0000 (-0700) Subject: Enable systemd to create /var/lib/lxc at runtime with StateDirectory X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c7bd5a3576f7449040e2164b6740c94cc2f5940c;p=thirdparty%2Flxc.git Enable systemd to create /var/lib/lxc at runtime with StateDirectory 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 --- 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]