lxd icon indicating copy to clipboard operation
lxd copied to clipboard

Feature request: storage volume permissions

Open jonathan-conder opened this issue 1 year ago • 7 comments

When creating a dir volume:

$ lxc storage volume create default foo

The mounted directory has permissions drwx--x--x (0711). It would be nice to have a config setting to control this. I'd be happy with just the dir driver for now, but we may want zfs as well in future.

It might be possible to work around this using something like:

$ mkdir -p backup/volume
$ $EDITOR backup/index.yaml
$ tar zcf foo.tar.gz backup
$ lxc storage volume import default foo.tar.gz foo

But generating index.yaml is a bit complex and I'm not sure if it's a stable format. Just saying I'd also be happy with an approach along these lines if it's easier to implement.

At the moment our use cache is to mount /var/cache/apt/archives as a volume. Normally this would have 0755 permissions, but as far as I can tell that doesn't really matter because apt runs as root. So I wouldn't treat this request as high priority, at least until we find a use case where the permissions really do matter.

jonathan-conder avatar Nov 21 '24 22:11 jonathan-conder

I'd be tempted to make this a property of the disk device that attaches the volume to an instance, rather than a property of the volume itself, as that then offers the option of having the same volume mounted to multiple instances using different mount perms.

tomponline avatar Nov 22 '24 08:11 tomponline

That's interesting, I didn't even know that was a possibility. Might be worth checking if this is already doable with raw.mount.options or something

jonathan-conder avatar Nov 26 '24 05:11 jonathan-conder

Something related recently landed in Incus https://github.com/lxc/incus/pull/1415

Thinking about this more the uid/gid maybe able to be device specific (if we consider idmapped mounts) however the permission of the volume directory itself would need to be on the volume indeed.

tomponline avatar Nov 26 '24 08:11 tomponline

What a coincidence! That feature looks like it would work for us

jonathan-conder avatar Nov 26 '24 21:11 jonathan-conder

As discussed, another option would be to allow mounting a subdirectory of a volume

jonathan-conder avatar Jun 11 '25 02:06 jonathan-conder

@jonathan-conder this PR from Incus may also help the situation:

https://github.com/lxc/incus/pull/1092

It allows to mount a sub-directory from a custom volume as a disk in the instance.

tomponline avatar Jun 11 '25 07:06 tomponline

Looks good to me!

jonathan-conder avatar Jun 11 '25 20:06 jonathan-conder