Hey everyone! I'm not completely new to LXC, but I'm having a tough time figuring out how UID and GID mapping works when it comes to my containers. I'm running a Proxmox machine with OpenMediaVault alongside it, and I've been bind-mounting some filesystem drives into the container. Previously, I had my drives formatted as NTFS, and everything was working fine. However, I recently reformatted them to EXT4 and now I'm facing access rights issues.
For instance, I created a file through SAMBA using the host's user, and it appears like this:
`-rw-rw-r-- 1 smeta users 0 Jan 17 08:02 uidguid`
But inside the LXC, the file looks like:
`-rw-rw-r-- 1 nobody nogroup 0 Jan 17 03:02 uidguid`
Here are the relevant UID and GID entries:
On the host:
`smeta:x:1000:100::/home/smeta:/usr/bin/bash`
`users:x:100:smeta`
In the LXC:
`qbtuser:x:1000:1000:,,,:/home/qbtuser:/bin/bash`
`users:x:100:qbtuser`
I've tried setting up the configurations by mapping the IDs in my `101.conf` file:
`lxc.idmap u 1000 1000 1`
`lxc.idmap g 100 100 1`
And in `/etc/subuid` and `/etc/subgid`, I have:
`root:1000:1`
`root:100000:65536`
`smeta:1000:1`
`smeta:165536:65536`
But despite these changes, LXC still assigns nobody/nogroup to the files. When I shut down the LXC, all the `lxc.idmaps` disappear from the `101.conf` file. I feel like I'm missing something crucial here, but I'm not sure what it is. Any help would be greatly appreciated!
1 Answer
It seems like you might not be mapping the full range for the IDs correctly, which is likely causing the issues you're facing. Try this setup for UID:
```
lxc.idmap = u 0 100000 1000
lxc.idmap = u 1000 1000 1
lxc.idmap = u 1001 101001 64535
```
And for GID:
```
lxc.idmap = g 0 100000 100
lxc.idmap = g 100 100 1
lxc.idmap = g 101 100101 65435
```
I can't test it at the moment, but this could fix your issue. Give it a shot!
Haha, I feel you! It took me a while to understand too when I first stumbled on it. I found the solution soon after my initial confusion, but there were still some other issues I needed to work out. Thanks for your input, though!