Lxd import -- Error: The container's directory "/var/snap/lxd/common/lxd/storage-pools/locedal-filestorage/containers/lxc4102" appears to be empty. Please ensure that the container's storage volume is mount

Hi,

since running: 3.19/stable: 3.19 2020-01-24 (13098) 67MB -

This problem occures:

# lxd import lxc4102
Error: The container's directory "/var/snap/lxd/common/lxd/storage-pools/local-filestorage/containers/lxc4102" appears to be empty. Please ensure that the container's storage volume is mounted



 #lxc storage list
+-------------------+-------------+--------+--------------------------------------+---------+
|       NAME        | DESCRIPTION | DRIVER |                SOURCE                | USED BY |
+-------------------+-------------+--------+--------------------------------------+---------+
| local-filestorage |             | dir    | /opt/storages/local-filestorage | 258     |
+-------------------+-------------+--------+--------------------------------------+---------+





# ls -la /opt/storages/local-filestorage/containers/lxc4102/
total 40
d--x------   5 1000000 root     4096 Sep  9 09:59 .
drwxr-xr-x 141 root    root     4096 Jan 24 14:02 ..
-r--------   1 root    root     3203 Dec 25 11:31 backup.yaml
drwx------   2 root    root    16384 Sep  9 09:59 lost+found
-rw-r--r--   1 root    root      275 Sep  9 09:59 metadata.yaml
dr-xr-xr-x  18 1000000 1000000  4096 Sep  8 09:23 rootfs
drwxr-xr-x   2 root    root     4096 Jan 24 14:03 templates

So, normally this would work. It worked at least in the past to place the container files in a storage and to import it.

But now LXD started to look inside of the snap directory, where nothing, of course, is mounted.

So how to get this stuff how imported ?

Thank you !
Greetings
Oliver

Hi,

I will try and re-create this locally and see what the problem is.

So I just tried this, and it worked OK from the snap.

The storage pool should have been mounted into /var/snap/lxd/common/lxd/storage-pools/local-filestorage from /opt/storages/local-filestorage.

Can I ask how you created the storage pool record for an existing storage pool directory?

Hi,

thats an install that was running for month with 260 containers.

But this snap autoupdate, again, killed a lot.

Anyway, the storage was created just like the docu says it. Its for sure not the problem.

Snap does some hidden mount there in its tree, that i can not see:

 # ls -lisa /var/snap/lxd/common/lxd/storage-pools/local-filestorage/
total 8
145162618 4 drwx--x--x 2 root root 4096 Apr 21  2019 .
145162612 4 drwx--x--x 3 root root 4096 Apr 21  2019 ..

But if you say you run the LXD snap 3.19 package and the lxd import works with old data, then i will have to try my luck with a reboot.

If you do

ps aux | grep lxd
Get PID of lxd process
sudo nsenter -t <LXD PID> -m
mount | grep local-filestorage

Then you should be able to see the mount.

I asked about creating the pool, as I was wondering how your container DB records were removed whilst the storage pool DB records still remained, really I am asking why do you need to import the container?

When I tried to simulate this, by first creating a container, and then removing the storage pool, when I tried to re-create the storage pool it wouldn’t let me create it with a non-empty directory.

Anyway, when LXD starts now, the storage pools are mounted, so this may resolve it for you.

Hi,

ah ok, no, i actually removed the lxd container to run this fix:

But, while this was working in the past, it does not work this time.

So if you want to try that on ur side, it would mean to

  • stop the $container
  • move /containers/$container somewhere else
  • delete $container
  • move the data back
  • execute lxd import $container

Got ya, ok will give it ago. I suspect an LXD restart will fix it, as 3.19 will mount storage pools on start now, but will test it.

Yep that works fine for me. Can you see if the mount is there for you inside the namespace and if not restart LXD?

Restarting LXD via snap did not work.

Going to reboot the server now :frowning:

OK please can you show me the output of mount from inside the lxd namespace, thanks.

Hi,

after a reboot:

# mount lxc4102-file-0 containers/lxc4102/
# lxd import lxc4102

… works.

I wonder why LXD always needs to give totally unneccessary hard times…

/dev/sda3 on /var/snap/lxd/common/lxd/storage-pools/local-filestorage type ext4 (rw,relatime)
/opt/storages/local-filestorage/lxc4102-file-0 on /var/snap/lxd/common/lxd/storage-pools/local-filestorage/containers/lxc4102 type ext4 (rw,relatime)

While actually this is mounted this way:

#mount /opt/storages/local-filestorage/lxc4102-file-0 /opt/storages/local-filestorage/containers/lxc4102/

These are qcow2 files we use to mount before we start the lxc container.

Anyway, Thomas, thank you very much for your feedback and help !

1 Like