As suggested by Stephan Grabber, I report it here since it is a snap issue and not a lxd one.
Distribution: ubuntu
Distribution version: 18.04
The output of “lxc info” or if that fails:
Kernel version: 4.18.0-16-generic
LXC version: 3.11
LXD version: 3.11 (snap)
Storage backend in use: DIR
If the home directory of a user don’t start by /home, lxc commands are not usable at all.
Steps to reproduce
Step one
As per the doc says, for a user to be abble to use lxc/lxd, he must belong to the group lxd.
So, I created a user for my needs :
$ useradd -g users -G lxd root-dns -d /appli/root-dns -m
$ ls -ld /appli/root-dns
drwxr-xr-x 3 root-dns users 4096 mars 20 12:26 root-dns/
$ su - root-dns
root-dns $ lxc list
cannot create user data directory: /appli/root-dns/snap/lxd/10343: Read-only file system
Step two
So, I went to the “old-way” :
$ usermod -d /home/root-dns root-dns
$ ls -ld /home/root-dns
drwxr-xr-x 3 root-dns users 4096 mars 20 12:25 root-dns
$ su - root-dns
root-dns $ lxc list
Gave the expected result, no error
Step three
I wanted to be sure, so I made this test :
$ usermod -d /home/root-users root-dns
$ ls -ld /home/root-users
drwxr-xr-x 3 root-dns users 4096 mars 20 17:12 /home/root-users
$ su - root-dns
root-dns $ lxc list
Again this worked fine.
So, my conclusion to this is that the home directory of any lxd user must be in /home, why is that so ? To me, this shouldn’t be mandatory and should work wherever the home directory is stored.
My original bug report to lxd can be viewed here : https://github.com/lxc/lxd/issues/5590
Hope there will be a way to handle this. As a matter of fact, an idea do do so (don’t know whether it can be easily done or not) : why not map host’s user directory ($HOME) to /home/whatever in the snap environment ? Whould that be so hard to code ? I don’t have that much knowledge of how snap and apparmor work together to tell if it is a good idea or not.