Define LXC/CT uid mappings *before* creation

nxet

Member
Sep 13, 2020
17
3
8
124
I'm running into this issue which I can't seem to solve on my own with man and the docs.
I tried many different configs to no avail and this honestly doesn't sound like something so hard, unless I'm missing a key point.
Either way, thanks in advance for pointing me in the right direction.

I'm looking for a way to define the uid/gid mappings for containers before the container itself is created. This is because the container is created mapping root to 100000:100000 by default, therefore most everything in the container's / is owned by that user.
When I then change my CT config in /etc/pve/lxc/<ctid>.conf and remap the uids/gids to a different id range (starting above 2000000), the resources in the filesystem become unavailable and it's impossible to access the container either via GUI or SSH.

arch: amd64
cores: 2
cpuunits: 256
hostname: hostname
memory: 512
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=52:F5:F4:C1:6E:6E,ip=dhcp,ip6=dhcp,type=veth
ostype: debian
rootfs: local-lvm:vm-2012-disk-0,size=3G
swap: 512
unprivileged: 1
lxc.idmap: u 0 2000000 65536
lxc.idmap: g 0 2000000 65536

I can still attach to the container running lxc-attach <ctid> on the host and the console works there, and with a ls -la / I can see the majority of directories and files are owned by nobody:nogroup.
Starting the container with lxc-start -F <ctid> allows to glance at the boot process, and as you can see from the attached file there are a bunch of errors.

To solve my problem I thought that creating the container with the correct mappings would have been helpful, but it is impossible via GUI and honestly I'm struggling to get past simply adding the .conf file in /etc/pve/lxc, because I obviously still need to create and provision the rootfs and I'm not sure how to proceed in a way that can work with Proxmox.
 

Attachments

  • boot.log
    8.1 KB · Views: 1
Think you have to map the rootfs after changing /etc/pve/lxc/

LXD once had a tool for that "fuidshift" you have to find a way to get that, I thought it was a static binary.
 
Thanks a lot for the heads up, it looks exactly like what I'm looking for.
Too bad it's not part of the standard suite, but I guess this is more niche than I thought it was.
Thanks again!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!