LXD doesn't start after ubuntu 16.04 upgrade to 18.04

Lxd does not start after upgrade. Output of ~# lxd --debug --group lxd below:

INFO[10-27|17:58:33] LXD 3.0.1 is starting in normal mode     path=/var/lib/lxd
INFO[10-27|17:58:33] Kernel uid/gid map:
INFO[10-27|17:58:33]  - u 0 0 4294967295
INFO[10-27|17:58:33]  - g 0 0 4294967295
INFO[10-27|17:58:33] Configured LXD uid/gid map:
INFO[10-27|17:58:33]  - u 0 100000 65536
INFO[10-27|17:58:33]  - g 0 100000 65536 
WARN[10-27|17:58:33] CGroup memory swap accounting is disabled, swap limits will be ignored.
INFO[10-27|17:58:33] Initializing local database
INFO[10-27|17:58:33] Initializing database gateway
INFO[10-27|17:58:33] Start database node                      address= id=1
INFO[10-27|17:58:33] Raft: Restored from snapshot 1-126-1540676210233
INFO[10-27|17:58:33] Raft: Initial configuration (index=1): [{Suffrage:Voter ID:1 Address:0}]
INFO[10-27|17:58:33] Raft: Node at 0 [Leader] entering Leader state
INFO[10-27|17:58:33] LXD isn't socket activated
INFO[10-27|17:58:33] Starting /dev/lxd handler:
INFO[10-27|17:58:33]  - binding devlxd socket                 socket=/var/lib/lxd/devlxd/sock
INFO[10-27|17:58:33] REST API daemon:
INFO[10-27|17:58:33]  - binding Unix socket                   socket=/var/lib/lxd/unix.socket
INFO[10-27|17:58:33] Initializing global database
INFO[10-27|17:58:33] Initializing storage pools
WARN[10-27|17:58:33] Incorrectly applied "storage_api" patch. Skipping storage pool initialization as it might be corrupt.
INFO[10-27|17:58:33] Applying patch: storage_api
DBUG[10-27|17:58:33] Database error: &errors.errorString{s:"sql: no rows in result set"}
EROR[10-27|17:58:33] Failed to query database: No such object.
EROR[10-27|17:58:33] Failed to start the daemon: No such object
INFO[10-27|17:58:33] Starting shutdown sequence
INFO[10-27|17:58:33] Stopping REST API handler:
INFO[10-27|17:58:33]  - closing socket                        socket=/var/lib/lxd/unix.socket
INFO[10-27|17:58:33] Stopping /dev/lxd handler
INFO[10-27|17:58:33]  - closing socket                        socket=/var/lib/lxd/devlxd/sock
INFO[10-27|17:58:33] Closing the database
INFO[10-27|17:58:33] Stop database gateway
INFO[10-27|17:58:33] Stop raft instance
INFO[10-27|17:58:33] Raft: Starting snapshot up to 139
INFO[10-27|17:58:33] Raft: Compacting logs from 1 to 11
INFO[10-27|17:58:33] Raft: Snapshot to 139 complete
INFO[10-27|17:58:33] Stopping REST API handler:
INFO[10-27|17:58:33] Stopping /dev/lxd handler
INFO[10-27|17:58:33] Stopping REST API handler:
INFO[10-27|17:58:33] Stopping /dev/lxd handler
INFO[10-27|17:58:33] Unmounting temporary filesystems
INFO[10-27|17:58:33] Done unmounting temporary filesystems
INFO[10-27|17:58:33] Saving simplestreams cache
INFO[10-27|17:58:33] Saved simplestreams cache
Error: No such object

It looks like the lxd.db was blown away at some point.

The LXDPool and logical volumes for each container still exist.

How do I get LXD to start successfully?

Assuming lxd.db is blown away, how do I run the existing containers?

FWIW, I apt-get purged lxd and reinstalled, mounted my old lvm images under …/storage-pools, and followed the lxd import instructions elsewhere: https://lxd.readthedocs.io/en/latest/backup/#container-backup-and-restore

Everything seems to have worked out fine. The installation of LXD 3.0.1 as a part of the ubuntu upgrade to 18.04 appears to have failed somewhere.

Edit: additionally, the LXDPool thinpool had to be renamed to LXDThinpool with lvrename.

Hi … Why don’t you switch to snap version ?
There its already in version 3.6 !

I don’t have a lot of time to spend on systems administration, and prefer to stick with LTS releases. I primarily use LXD on a single home server to separate various functions (plex, pbx, unifi controller, etc.). Even older versions work very well for this purpose.

Hi again,

So in my understanding you made a mess on your system and you don’t have time to fix it.
I just sent you a suggestion that fix it in 2 minutes.
Sure you have to save the images and container in some place if you need to migrate. It’s up to you.

Note that gradually LXD is migrating to snap package, that Ubuntu 16.04 don’t have version 3.xx from deb repository. I personally use Ubuntu 16.04 and I build my own version every week and it cost me about 1 minute of my time.