"lxc image list" command output is empty

Hello

I have lxd 3.6 9437 on ubuntu 18.10.
I have 4 containers but lxc image list command is empty.
I can also see in zfs list there is a image in lxd/images directory.

@ritchie:~$ lxc list
±-----±--------±----------------±-----±-----------±----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
±-----±--------±----------------±-----±-----------±----------+
| coin | RUNNING | 10.0.0.X (eth0) | | PERSISTENT | |
±-----±--------±----------------±-----±-----------±----------+
| nas | RUNNING | 10.0.0.X (eth0) | | PERSISTENT | |
±-----±--------±----------------±-----±-----------±----------+
| p2p | RUNNING | 10.0.0.X (eth0) | | PERSISTENT | |
±-----±--------±----------------±-----±-----------±----------+
| web | RUNNING | 10.0.0.X (eth0) | | PERSISTENT | |
±-----±--------±----------------±-----±-----------±----------+
maxim@ritchie:~$ lxc image list
±------±------------±-------±------------±-----±-----±------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE |
±------±------------±-------±------------±-----±-----±------------+
@ritchie:~$ zfs list
NAME USED AVAIL REFER MOUNTPOINT
rpool 229G 220G 96K /
rpool/ROOT 2.85G 220G 2.85G /
rpool/home 228K 220G 228K /home
rpool/srv 209G 220G 96K /srv
rpool/srv/lxd 12.0G 220G 96K none
rpool/srv/lxd/containers 11.3G 220G 96K none
rpool/srv/lxd/containers/coin 6.07G 220G 6.16G /var/snap/lxd/common/lxd/storage-pools/default/containers/coin
rpool/srv/lxd/containers/nas 1.11G 220G 1.19G /var/snap/lxd/common/lxd/storage-pools/default/containers/nas
rpool/srv/lxd/containers/p2p 931M 220G 1020M /var/snap/lxd/common/lxd/storage-pools/default/containers/p2p
rpool/srv/lxd/containers/web 3.24G 220G 3.33G /var/snap/lxd/common/lxd/storage-pools/default/containers/web
rpool/srv/lxd/custom 96K 220G 96K none
rpool/srv/lxd/deleted 192K 220G 96K none
rpool/srv/lxd/deleted/images 96K 220G 96K none
rpool/srv/lxd/images 707M 220G 96K none
rpool/srv/lxd/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610 707M 220G 707M none
rpool/srv/lxd/snapshots 96K 220G 96K none
rpool/swap 17.0G 237G 60K -

Could you please explain why lxc image list command output is empty?

Thanks In advance,
Maxim

What do you have in /var/snap/lxd/common/lxd/images?

nothing
root@ritchie:~# ls -la /var/snap/lxd/common/lxd/images
total 33
drwx------ 2 root root 2 Jun 6 17:02 .
drwxr-xr-x 16 lxd nogroup 20 Nov 8 09:41 …
root@ritchie:~#

Ok, so the output is correct, you simply don’t have any image in your local image store.

Not sure why you have a leftover one in your zpool though, can you try (but don’t force it):

  • zfs destroy rpool/srv/lxd/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610@readonly
  • zfs destroy rpool/srv/lxd/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610

I cannot do it I’'ll lose my containers I suppose.

root@ritchie:~# zfs destroy rpool/srv/lxd/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610@readonly

cannot destroy ‘rpool/srv/lxd/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610@readonly’: snapshot has dependent clones

use ‘-R’ to destroy the following datasets:

rpool/srv/lxd/containers/p2p

rpool/srv/lxd/containers/web

rpool/srv/lxd/containers/coin

rpool/srv/lxd/containers/nas

root@ritchie:~# zfs destroy rpool/srv/lxd/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610

cannot destroy ‘rpool/srv/lxd/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610’: filesystem has children

use ‘-r’ to destroy the following datasets:

rpool/srv/lxd/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610@readonly

root@ritchie:~#

Where is the image the containers were based on?
Why I cannot see it “lxc image list” output ?

Ok, so it’s an expired image that hasn’t been archived properly.

zfs rename rpool/srv/lxd/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610 rpool/srv/lxd/deleted/images/9879a79ac2b208c05af769089f0a6c3cbea8529571e056c82e96f1468cd1f610 will move it to where it should be.

The image your containers were created from has expired and has been automatically deleted from the image store. Internally a ZFS version of the image is kept around as deleting that would cause your containers to be deleted (as you noticed above).

The main issue is that the image should have been renamed to deleted/images/SHA256 at the same time it got removed from the database and from /var/snap/lxd/common/lxd/images but clearly that failed somehow at the time.

Thanks a lot for support!!!