]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Enable systemd to create /var/lib/lxc at runtime with StateDirectory 4583/head
authorVishwas Udupa <vudupa@qti.qualcomm.com>
Wed, 17 Sep 2025 10:56:09 +0000 (03:56 -0700)
committerVishwas Udupa <vudupa@qti.qualcomm.com>
Thu, 18 Sep 2025 06:04:28 +0000 (23:04 -0700)
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 <vudupa@qti.qualcomm.com>
Co-developed-by: Raghuvarya S <raghuvar@qti.qualcomm.com>
config/init/systemd/lxc.service.in
config/init/systemd/lxc@.service.in

index 397a6c4d042bf1949954c2e12d64bd710b4ae6d6..71426561787f4319065de0997e5258d7b3f92683 100644 (file)
@@ -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]
index 21ce64aefe9bc2a07fdc353e4d3ca4204ac40dc3..44e5b14dd2c1a57ad3b43a2f323562287993e474 100644 (file)
@@ -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]