I'm trying to figure out UID/GID remapping to access mounts from within an unprivileged container. I believe I am doing everything according to the wiki, but I'm still getting odd behavior. System configuration is as follows:
Everything works as expected at this point. The user can access their normal /home/worker directory and write to it. I can read the mount points, but can't write to them.
Adding the following should remap the user to read/write the mount directories. In the container conf file I add:
Add
I still cannot write to the mounted directories. I went back and commented out the idmaps and chowned the folder to the 101000 ID number and everything worked, but this does not appear to be an ideal solution as things get more complicated down the road.
Furthermore, while the remaps are active, the remapped user can no longer write to their own home directory, which leads to interesting errors/warnings with tools like nano.
Any information would be appreciated. If there's a better way to allow unprivileged containers to read/write mounted directories, I'd like to know.
- pve 6.4. Fully updated
- ZFS is used as root
- ZFS is used on several volumes of various drives/ssds and mounted generically in the root file system as /testing /bulk and so on.
- unprivileged container has a mount point set with
mp0: directory/on/ZFS/pool,mp=/arbitrary/directory
in the /ect/pve/lxc/###.conf - unprivileged ubuntu container has user created with
useradd -u 1000 -m worker
Everything works as expected at this point. The user can access their normal /home/worker directory and write to it. I can read the mount points, but can't write to them.
Adding the following should remap the user to read/write the mount directories. In the container conf file I add:
Code:
lxc.idmap: u 0 100000 1000
lxc.idmap: g 0 100000 1000
lxc.idmap: u 1000 1000 1
lxc.idmap: g 1000 1000 1
lxc.idmap: u 1001 101001 64535
lxc.idmap: g 1001 101001 64535
root:1000:1
to /etc/subgid
and /etc/subuid
.chown -R 1000:1000 /mounted/folder
I still cannot write to the mounted directories. I went back and commented out the idmaps and chowned the folder to the 101000 ID number and everything worked, but this does not appear to be an ideal solution as things get more complicated down the road.
Furthermore, while the remaps are active, the remapped user can no longer write to their own home directory, which leads to interesting errors/warnings with tools like nano.
Code:
Unable to create directory /home/worker/.local/share/nano/: Permission denied
It is required for saving/loading search history or cursor positions.
Any information would be appreciated. If there's a better way to allow unprivileged containers to read/write mounted directories, I'd like to know.