Error: Source path "/var/lib/snapd/hostfs/mnt" isn't empty

hi there, im trying to create a storage pool on nfs storage . i mounted it under /mnt but when i go to create it there with the “dir” driver it gives me the title error.

so i mounted the nfs folder under the “hostfs” directory and then i can add it but it shows as “UNAVAILABLE” so it cant be used

Hi! Let’s see if we can get this sorted.

Just from the top of my head, considering the first attempt of mounting it on /mnt, if there is something in your /mnt/<nfs-path> and you don’t want to delete it, I believe you could just create a subdirectory, as in /mnt/<nfs-path>/lxd-source-dir and use that as a source in lxc storage create my-nfs dir source=/mnt/<nfs-path>/lxd-source-dir. Does that apply to your case?

If that doesn’t help, could you please provide a step by step reproduction of the issue to help us investigate further?

yes sorry i cut off the last folder but it was in fact in a dedicated subfolder. the issue is that instead of looking in that path lxd is trying defaulting to /var/lib/snapd/hostfs/ and then adding the path i input.

sudo lxc storage create my-nfs dir source=/mnt/nfsmount/lxd-source-dir
Error: Source path "/var/lib/snapd/hostfs/mnt/nfsmount/lxd-source-dir" doesn't exist

if i try to workaround by mounting the nfs directly into this hostfs snap folder(which looks pretty wrong) then i can succesfully create the storage but it then will show up as UNAVAILABLE

Indeed mounting directly under hostfs would not be advisable, the source path shows as being under /var/lib/snapd/hostfs because this is where the host’s original root dirctory gets “mounted” to when inside the snap’s mount namespace. In short, on the snap’s view of the filesystem, the root directory shows as /var/lib/snapd/hostfs, so /mnt shows as /var/lib/snapd/hostfs/mnt. More information on this here.

It caught my attention that the error you provided on the last message says:

Error: Source path "/var/lib/snapd/hostfs/mnt/nfsmount/lxd-source-dir" doesn't exist

And considering that setting the source for a pool does not automatically creates a directory under the specified path, but instead it should be created in advance. It possible that simply creating lxd-source-dir with mkdir /var/lib/snapd/hostfs/mnt/nfsmount/lxd-source-dir before running sudo lxc storage create my-nfs dir source=/mnt/nfsmount/lxd-source-dir can help?

What does ls /mnt show?

The directory needs to be empty to create a storage pool there.

ok finally worked, yes my directory was not empty but the different path in the error message really confused me

once i set the path to an existent empty directory it worked

2 Likes