As it is common, lxd
provides two systemd units: lxd.socket
and lxd.service
. When lxd.socket
is started, it starts lxd.service
as soon as any application (such as lxc
) tries to access the lxd daemon.
I would like lxd
to start on boot, without having to run any command. However, when I try to enable lxd.service
, it enables lxd.socket
instead:
# systemctl enable lxd.service
Created symlink /etc/systemd/system/sockets.target.wants/lxd.socket → /usr/lib/systemd/system/lxd.socket.
What is going on here? How can I enable lxd.service
?
The system is running Fedora 39. These are the unit files:
/usr/lib/systemd/system/lxd.service
:
[Unit]
Description=LXD - main daemon
After=network-online.target openvswitch-switch.service lxcfs.service lxd.socket
Requires=network-online.target lxcfs.service lxd.socket
Documentation=man:lxd(1)
[Service]
Environment=LXD_DOCUMENTATION=/usr/share/doc/lxd-doc/html
Environment=LXD_OVMF_PATH=/usr/share/edk2/ovmf
Environment=LXD_UI=/usr/share/lxd-ui/ui
ExecStart=/usr/bin/lxd --group lxd
ExecStartPost=/usr/bin/lxd waitready --timeout=600
KillMode=process
TimeoutStartSec=600s
TimeoutStopSec=30s
Restart=on-failure
LimitNOFILE=1048576
LimitNPROC=infinity
TasksMax=infinity
[Install]
Also=lxd-containers.service lxd.socket
/usr/lib/systemd/system/lxd.socket
:
[Unit]
Description=LXD - unix socket
Documentation=man:lxd(1)
[Socket]
ListenStream=/var/lib/lxd/unix.socket
SocketGroup=lxd
SocketMode=0660
Service=lxd.service
[Install]
WantedBy=sockets.target
The behavior you're seeing is driven by the
Also
keyword in the service unit, which you can read about here.Because the service unit does not specify a
WantedBy
(orRequiredBy
) directive in the[Install]
section, thisAlso
means effectively "instead": when yousystemctl enable lxd.service
, instead enablelxd-containers.service
andlxd.socket
.You could try simply adding
WantedBy=default.target
to the[Install]
section, so that thelxd
service is started automatically at boot. Don't forget tosystemctl daemon-reload
after editing the unit (or after creating a drop-in config).