When the LXD snap updated to 4.5, none of my X11 enabled containers was able to start. This issue is already being discussed in the 4.5 announcement thread.
I tried to revert to the previous version using first sudo snap revert lxd (just changed revision but staed at 4.5) then calling snap refresh --channel=4.4/stable.
The channel change somehow disrupted the database of containers. lxc list showed nothing. Calling back snap refresh --channel=4.5/stable didn’t help either, so I started to mount the respective zfs containers following Simos’ blog post.
I was able to recover only one of them - the one that has no X11 profile enabled. The remaining 17 containers return an error:
sudo lxd import xyz
Error: The instance's directory "/var/snap/lxd/common/lxd/storage-pools/default/containers/xyz" appears to be empty. Please ensure that the instance's storage volume is mounted
I checked the path and no, it is not empty. Everything is there: backup.yaml, metadata.yaml, rootfsandtemplates`.
Please help me to figure out how I can recover all the containers. I use them for my work and this is a very serious problem for me.
Ok, lets try to get things back online in a more reasonable way first.
Can you show ls -lh /var/snap/lxd/common/lxd/database?
With a bit of luck, your backups are usable and we can just get you back on 4.5, then upgrade to 4.6 and get you the fix I just submitted to fix the X11 thing.
(LXD automatically makes a backup before performing schema changes, this makes it bulletproof should a version upgrade fail, however, attempts at downgrading or reinstalling could have triggered another backup, eliminating the previous backup in the process…)
So zfs was alrady mounted for all. I had to recreate some profiles (like X11). Around half of the containers recovered fine, but some didn’t. I see no pattern there. The error is the same (the instance’s dir appears to be empty) but I can confirm that there are all files as expected in /var/snap/lxd/common/lxd/storage-pools/default/containers/mycontainer
lxd init is a wizard that guides you to create a baseline configuration so that you can create containers straight away. If something is missing, like lxdbr0, then you can just create it using lxc network. No need to run lxd init again.
Here is how to re-create lxdbr0, if none exists.
ubuntu@mycontainer:~$ sudo lxc network list
+------+------+---------+-------------+---------+
| NAME | TYPE | MANAGED | DESCRIPTION | USED BY |
+------+------+---------+-------------+---------+
ubuntu@mycontainer:~$ sudo lxc network create lxdbr0
Network lxdbr0 created
ubuntu@mycontainer:~$ sudo lxc network list
+--------+--------+---------+-------------+---------+
| NAME | TYPE | MANAGED | DESCRIPTION | USED BY |
+--------+--------+---------+-------------+---------+
| lxdbr0 | bridge | YES | | 0 |
+--------+--------+---------+-------------+---------+
ubuntu@mycontainer:~$