Failures on installing LXD on Ubuntu20.04 and systemctl errors

I am installing LXD 4.0 on Ubuntu 20.04 using sudo apt-get install lxd
The installation prints out the following failures
Failed to stop lxd.socket: Unit lxd.socket not loaded.
Failed to stop lxd.service: Unit lxd.service not loaded.
Failed to stop lxd-containers.service: Unit lxd-containers.service not loaded.
Failed to disable unit: Unit file lxd.socket does not exist.

In addition, when I run command sudo systemctl status lxd, it reports
Unit lxd.service could not be found.

Please help me letting me know how to resolve such problems. Thanks.
The entire LXD installation prints are pasted below for reference.


Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
lxd
0 upgraded, 1 newly installed, 0 to remove and 160 not upgraded.
Need to get 5,444 B of archives.
After this operation, 79.9 kB of additional disk space will be used.
Get:1 Index of /ubuntu focal/universe amd64 lxd all 1:0.9 [5,444 B]
Fetched 5,444 B in 0s (14.7 kB/s)
Preconfiguring packages …
Selecting previously unselected package lxd.
(Reading database … 154436 files and directories currently installed.)
Preparing to unpack …/archives/lxd_1%3a0.9_all.deb …
=> Installing the LXD snap
==> Checking connectivity with the snap store
==> Installing the LXD snap from the 4.0 track for ubuntu-20.04
lxd (4.0/stable) 4.0.6 from Canonical\u2713 installed
=> Snap installation complete
==> Cleaning up leftovers
Failed to stop lxd.socket: Unit lxd.socket not loaded.
Failed to stop lxd.service: Unit lxd.service not loaded.
Failed to stop lxd-containers.service: Unit lxd-containers.service not loaded.
Failed to disable unit: Unit file lxd.socket does not exist.
Unpacking lxd (1:0.9) …
Setting up lxd (1:0.9) …

Starting with 18.10, Ubuntu does not ship LXD as a deb.
Installing the deb like you did causes the snap to be installed instead.

systemctl status snap.lxd.daemon most likely works fine in this case.

The errors you’re getting are the migration steps normally run to handle upgrades from 18.04 to 20.04 where those installs automatically get converted to the snap.

1 Like

Thank you so much for quick and clear explanation!
Yes, systemctl status snap.lxd.daemon works well.
I would assume that systemctl enable/start/restart ... works in the same way, correct?
Again, really appreciate your help!

When using the snap package LXD has socket activation which means the first time you try to connect to it using lxc command it will start lxd, or if you have instances set to start on boot then it will start automatically.

Please take note that there is a difference between reloading and restarting LXD.

Running sudo systemctl reload snap.daemon.lxd LXD will cause the LXD process to exit and restart (this is what happens when a new version of the snap is released), but this does not restart your instances.

However running sudo systemctl restart snap.daemon.lxd will cause LXD to shutdown all of your instances, then restart and bring them back up again.

For more info on managing the snap package please see Managing the LXD snap

Hello, @tomp, I finally got time to read through your recommend article. Thank you very much for the tips!
I used apt install lxd to run the installation and, as mentioned by Stephane, it invoked snap to complete the installation. I recall that I was provided the choices among latest, 4.0 and 3.0. And I selected 4.0. I think that it is equivalent to --channel=4.0/stable and it will not get any new feature updates automatically, if my understanding is correct.
Is there any way that I can confirm which track I used for the LXD installation? Thank you.

Hi, running this will tell you:

snap info lxd | grep installed

installed: 4.0.6 (20326) 70MB -
Thank you!

I know this threads a couple years old but I’m running into many of the same errors in the OP.

Reading this thread it seemed to kind of die without any specific resolution to what was causing the errors.

At least as I read the comments it didn’t seem that anybody said “this caused the problem” and here’s how to fix it.

So if anyone might know those answers then if you could leave another comment here as to resolution I’d appreciate it.

I got through the issues, bypassed or fixed, I don’t remember.
There could be many reasons leading to the same issue/symptoms. Yours are very unlikely the same as mine. It’s probably better off you could start a new thread and look for more experts’ help here.

1 Like

Yeah I didn’t think the cause was necessarily the same as mine I was more interested in what the final solution was because the comments as I mentioned seem to just end

Thanks for responding