Mounting container storage volume

Hi,

I’m moving this discussion to a new thread from: Failed to start dqlite server to avoid it getting well off topic. I also apologise in advance, as I’m pretty sure this is a stupid question: I’m just struggling to find a quick answer to it.

I am trying to import my containers after a database corruption.

sudo lxd import duplicity-1604
Error: The container's directory "/var/snap/lxd/common/lxd/storage-pools/default/containers/duplicity-1604" appears to be empty. Please ensure that the container's storage volume is mounted

From: https://lxd.readthedocs.io/en/latest/backup/#disaster-recovery

To use the disaster recovery mechanism, you must mount the container’s storage to its expected location, usually under storage-pools/NAME-OF-POOL/containers/NAME-OF-CONTAINER .

How do I actually do that? Everything should be in the default locations, as I learnt to my surprise that launching a new container with the same name gave me access to my files.

What storage backend are you using?

Hi!
I have a similar problem. I want to restore the container from the volume located on ceph pool. I see it on each member of the cluster, but how to mount it? Thanks!

For CEPH, you’re going to have to use rbd map for the container’s RBD volume, then mount the resulting /dev/rbd device onto the storage directory in /var/snap (/var/snap/lxd/common/lxd/storage-pools/POOL-NAME/containers/NAME).

After that lxd import NAME should import the backup.yaml and create the database entries as needed for the container.

Ok. Thank you! It worked as expected.

I think I used ZFS on this machine:

$ lxc storage list
+---------+-------------+--------+--------------------------------------------+---------+
|  NAME   | DESCRIPTION | DRIVER |                   SOURCE                   | USED BY |
+---------+-------------+--------+--------------------------------------------+---------+
| default |             | zfs    | /var/snap/lxd/common/lxd/disks/default.img | 5       |
+---------+-------------+--------+--------------------------------------------+---------+

Ok, so same thing, you need to have those datasets mounted so that lxd import can find the needed data.

That will usually involve zfs list -t all to see all the datasets and then run zfs mount DATASET for each of them to have them mounted, lxd import should then be much happier.

Many thanks @stgraber, that saved me a fair bit of time (I don’t use zfs hardly ever). All seems working perfectly now.

For me I originally got a:

$ zfs list -t all
no datasets available

Until I started another one of the lxd containers, then they showed up. Then, as you say, a zfs mount NAME and the lxd import worked correctly.

It would be really neat if some of this was built into the lxd import process (if you were still using the same default storage pool etc). Here, for example, it would have been great to get a prompt that there was an unmounted dataset with the name default/containers/[the name of the container I was trying to import] and to offer to sort that for me.