Skip to content

Commit c7bd5a3

Browse files
committed
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 <vudupa@qti.qualcomm.com> Co-developed-by: Raghuvarya S <raghuvar@qti.qualcomm.com>
1 parent df8cf80 commit c7bd5a3

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

config/init/systemd/lxc.service.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ExecStop=@LIBEXECDIR@/lxc/lxc-containers stop
1313
ExecReload=@LIBEXECDIR@/lxc/lxc-apparmor-load
1414
# Environment=BOOTUP=serial
1515
# Environment=CONSOLETYPE=serial
16+
StateDirectory=lxc
1617
Delegate=yes
1718

1819
[Install]

config/init/systemd/lxc@.service.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ExecStart=@BINDIR@/lxc-start -F -n %i
1313
ExecStop=@BINDIR@/lxc-stop -n %i
1414
# Environment=BOOTUP=serial
1515
# Environment=CONSOLETYPE=serial
16+
StateDirectory=lxc
1617
Delegate=yes
1718

1819
[Install]

0 commit comments

Comments
 (0)