I have read the earlier discussion of this or a similar issue, but it did not help me.
The LXD service will not start on boot:
$ systemctl status lxd.service
....Dependency failed for LXD - main daemon
$ systemctl status lxd.socket
...lxd.socket: Failed to listen on sockets: No such file or directory
However, after the system starts, I can start the service manually without error:
Is there something on your system which would explain /var/lib/lxd not existing early in the boot sequence but then existing later on? Is /var on a different partition for example?
Note that LXD is known to have issues when /var/lib/lxd is a symlink, this isn’t a supported setup and you really should be switching to a bind-mount which would get you the same behavior but not confused the kernel (especially apparmor) quite as much.
Thanks. I had a bind mount, but eventually had a problem with that when lxd started creating files in the mount point folder before the partition was mounted.
I have solved this now by running sudo systemctl edit lxd.socket and adding:
[Unit]
ConditionPathIsMountPoint=/lxd
With this new condition, It’s probably safe to go back to the bind mount. What really irritates me is systemd starting all kinds of services before fstab is fully processed.