LXD v3, Failed to start the daemon: Both legacy and new local database files exists

Any idea why i cam getting that message. Running v3 on Ubuntu bionic gives me

# lxd --group lxd -d
INFO[05-05|16:12:05] LXD 3.0.0 is starting in normal mode     path=/var/snap/lxd/common/lxd
INFO[05-05|16:12:05] Kernel uid/gid map: 
INFO[05-05|16:12:05]  - u 0 0 4294967295 
INFO[05-05|16:12:05]  - g 0 0 4294967295 
INFO[05-05|16:12:05] Configured LXD uid/gid map: 
INFO[05-05|16:12:05]  - u 0 1000000 1000000000 
INFO[05-05|16:12:05]  - g 0 1000000 1000000000 
WARN[05-05|16:12:05] CGroup memory swap accounting is disabled, swap limits will be ignored. 
INFO[05-05|16:12:05] Initializing local database 
EROR[05-05|16:12:05] Failed to start the daemon: Both legacy and new local database files exists 
INFO[05-05|16:12:05] Starting shutdown sequence 
DBUG[05-05|16:12:05] Not unmounting temporary filesystems (containers are still running) 
INFO[05-05|16:12:05] Saving simplestreams cache 
INFO[05-05|16:12:05] Saved simplestreams cache 
Error: Both legacy and new local database files exists

# ls -la  /var/snap/lxd/common/lxd/
total 122
drwxr-xr-x 16 root root     20 May  5 21:27 .
drwxr-xr-x  5 root root      9 May  6  2018 ..
drwx------  2 root root      4 Mar 31 01:48 cache
drwx--x--x  2 root root      8 Apr  1 19:10 containers
drwx------  3 root root      4 May  6  2018 database
drwx--x--x  8 root root      8 May  5 20:29 devices
drwxr-xr-x  2 root root      2 Mar 31 01:29 devlxd
drwx------  2 root root      2 Mar 31 01:29 disks
drwx------  2 root root      4 Apr 15 04:52 images
drwx------  8 root root     12 May  6  2018 logs
-rw-r--r--  1 root root  40960 May  5 13:29 lxd.db
-rw-r--r--  1 root root 212992 May  5 07:51 lxd.db.bak
drwx--x--x  3 root root      3 May  5 20:00 networks
drwx------  3 root root      7 May  5 13:29 raft
drwx------  4 root root      4 Mar 31 01:33 security
-rw-r--r--  1 root root   1927 Mar 31 01:29 server.crt
-rw-------  1 root root   3247 Mar 31 01:29 server.key
drwx--x--x  2 root root      2 Mar 31 01:29 shmounts
drwx------  2 root root      2 Mar 31 01:29 snapshots
drwx--x--x  3 root root      3 Mar 31 01:29 storage-pools

# snap list
Name  Version    Rev   Tracking  Developer  Notes
core  16-2.32.5  4486  stable    canonical  core
lxd   3.0.0      6954  stable    canonical  -

Any idea what could be the issue?

Hmm, that’s odd. I guess something blew up in the middle of the upgrade.

Run mv /var/snap/lxd/common/lxd.db /var/snap/lxd/common/lxd.db.old and then try starting LXD again. Let us know if you’re missing containers or anything, in which case that lxd.db.old file may end up useful.

I had the same problem: I had a scheduled backup of the LXD database that would recreate an empty lxd.db file. I updated my backup script so it would point to the database subdir instead.

BTW, how do we restart lxd when installed as a snap?

systemctl reload snap.lxd.daemon that’s the easiest way to restart LXD without also restarting the containers

After doing this i get the following error,

# LXD_DIR=/var/snap/lxd/common/lxd lxd 
WARN[07-04|00:37:44] AppArmor support has been disabled because of lack of kernel support 
WARN[07-04|00:37:44] Couldn't find the CGroup network class controller, network limits will be ignored. 
EROR[07-04|00:37:44] Failed to start the daemon: failed to create raft factory: both legacy and new global database directories exist 
Error: failed to create raft factory: both legacy and new global database directories exist

Try to also do mv /var/snap/lxd/common/raft /var/snap/lxd/common/raft/old and then try starting LXD again.

I did mv /var/snap/lxd/common/raft /var/snap/lxd/common/raft.old and LXD did start with a bunch of warnings about backup.yaml,

# LXD_DIR=/var/snap/lxd/common/lxd lxd 
WARN[07-04|00:48:53] AppArmor support has been disabled because of lack of kernel support 
WARN[07-04|00:48:53] Couldn't find the CGroup network class controller, network limits will be ignored. 
WARN[07-04|00:48:54] Unable to update backup.yaml at this time name=dbserver

Looking closely it did not start all the containers. For example i have a unifi container,

# ls -la /var/snap/lxd/common/lxd/containers/unifi
lrwxrwxrwx 1 root root 63 May 27 21:13 /var/snap/lxd/common/lxd/containers/unifi -> /var/snap/lxd/common/lxd/storage-pools/default/containers/unifi

lxc list doesnt show this container.

Starting LXD with the debug option (-d) also has no mention of this container!

Poking at the /var/log/lxd.log shows
container=unifi err="Failed to run: ebtables -L --Lmac2 --Lx: The kernel doesn't support the ebtables 'filter' table." lvl=eror msg="Unable to remove network filters"

I built the ‘filter’ module in the kernel and rebooted the system. Unfortunately, there is no mention of the ‘unifi’ container in /var/log/lxd/lxd.log.


lxd import unifi worked following this post.

Ok, good that lxd import solved it. Otherwise I’d have suggested to try moving the database around to see if the “old” ones are actually newer than the ones you’ve got in the database directory.