[solved] Upgrade to 20.04 LTS broke lxd installation

I upgraded my running web server from bionic to the latest Ubuntu LTS version (by accident) and during this process my running lxd installation has been broken. As I am not familiar with the latest snap lxd version I ask you to help me fix this. FYi I had all containers on a dedicated btrfs partition mounted to /var/lib/lxd

The problem is:
“lxc list” does not show any container.
“lxc network list” does not show the previously configured lxd brige
“lxc info” shows I am using version 4.0.2 but nothing usable for me atm. I can provide all info if needed

A list in /var/lib/lxd/containers/ shows me broken symlinks to /var/snap/lxd/common/lxd/storage-pools/default/containers/ (which is empty)
The cobntainers are located in /var/lib/lxd/storage-pools/default/containers
I changed the symlink, but that does not help to show and get the containers running

What else do I have to do to restore my containers?


And this might also help (it’s for zfs, but I guess it can also be helpful for btrfs):

You might need to look up specifics for btrfs.


Can you show lxc version?

You’re going to need to change your /etc/fstab entry to mount your storage at /var/snap/lxd/common/lxd rather than /var/lib/lxd, then I’d recommend rebooting your system and checking if things look any better.

The deb->snap upgrade logic detects and prints a warning to update /etc/fstab, but this may have been hidden by all the other upgrade messages.

1 Like

You’re going to have to undo what you did to the symlinks though or your container will fail to start.

Hi Stephane,
Hi all,

thanks for your answers!

ubuntu ships 4.0.2 as stable version

lxc version
Client version: 4.0.2
Server version: 4.0.2

I will check your suggestion and undo my changes and modify /etc/fstab to mount the volume to /var/snap/lxd/common/lxd

Ok, a failure to move your data would have made the upgrade fail very visibly.
So there’s a very good chance that everything upgraded properly and that the only issue you ran into is that after a reboot, your data was getting mounted on /var/lib/lxd rather than /var/snap/lxd/common/lxd

We did consider trying to auto-update /etc/fstab, but this could have some rather disastrous consequences so we decided to just print a warning instead.

Thanks a lot, that solved my issue!
Everything is fine after a reboot.

Hi there, I believe I am having the same issue, but I am very rusty as I am stepping back into Linux after a long break…

I have just booted up a Linux box after it was dormant for about a year. After updating to 20.04, I am having a ton of graphical issues and it seems that LXD has been messed up a bit.

After running:

sudo apt --fix-broken install

I get:

Preconfiguring packages …
(Reading database … 538488 files and directories currently
Preparing to unpack …/archives/lxd_1%3a0.7_all.deb …
Warning: Stopping lxd.service, but it can still be activated
=> Installing the LXD snap
==> Checking connectivity with the snap store
==> Installing the LXD snap from the latest track for ubuntu-
snap “lxd” is already installed, see ‘snap help
==> Waiting for LXD to be online (10min timeout)
==> Running migration from Deb to Snap
=> Connecting to source server
=> Connecting to destination server
=> Running sanity checks
error: Target LXD already has containers, aborting.
dpkg: error processing archive /var/cache/apt/archives/lxd_1%
3a0.7_all.deb (–unpack):
new lxd package pre-installation script subprocess returned
> error exit status 1
> Job for lxd-containers.service failed because the control pro
> cess exited with error code.
> See “systemctl status lxd-containers.service” and "journalctl
> -xe" for details.
> Errors were encountered while processing:
> /var/cache/apt/archives/lxd_1%3a0.7_all.deb
> E: Sub-process /usr/bin/dpkg returned an error code (1)

LXC Version:

Client version: 4.3
Server version: 4.3

If I run > systemctl status lxd-containers.service

lxd-containers.service - LXD - container startup/shutdown
Loaded: loaded (/lib/systemd/system/lxd-containers.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2020-07-12 21:59:58 PDT; 10min ago
Docs: man:lxd(1)
Main PID: 19134 (code=exited, status=1/FAILURE)

Jul 12 21:59:58 czar systemd[1]: Starting LXD - container startup/shutdown…
Jul 12 21:59:58 czar lxd[19134]: Error: User “root” has no subuids
Jul 12 21:59:58 czar systemd[1]: lxd-containers.service: Main process exited, code=exited, status=1/FAILURE
Jul 12 21:59:58 czar systemd[1]: lxd-containers.service: Failed with result ‘exit-code’.
Jul 12 21:59:58 czar systemd[1]: Failed to start LXD - container startup/shutdown.

I believe it is similar to the above, but I do not know what exactly to add to the fstab to update the necessary links. Any help on this would be great. 18.04 was working great, now I am stuck in 4:3 resolution.

Please let me know if I am missing any necessary information.

Thank you!

Ok, so what the error is saying is that you have both the snap and deb installed on the system, so it’s refusing to migrate your deb install over to snap as that would lead to losing the containers running on the snap version of LXD.

So let’s try to figure out what’s where, can you show:

  • ls -lh /var/snap/lxd/common/lxd/containers
  • ls -lh /var/lib/lxd/containers
  • ls -lh /var/snap/lxd/common/lxd/storage-pools
  • ls -lh /var/lib/lxd/storage-pools

If we can confirm that the deb side (/var/lib/lxd) is effectively unused, then we can just nuke it and bring things back to normal. If there are actually containers in both deb and snap, we’ll need to be a bit more careful :slight_smile: