Archived
Fix LXC container creation: unprivileged, nesting/keyctl, swap sizing
Check NixOS configurations / eval-hosts (push) Failing after 10m48s
Check NixOS configurations / eval-hosts (push) Failing after 10m48s
Found and fixed live against a real test container (VMID 100, lxc-nix-cache on pve.sweet.home) after the previous pct-restore-to-pct-create fix still produced a container that booted into garbled console output: 1. pct create's own CLI default for --unprivileged is privileged (unlike the web UI, whose checkbox defaults the other way), but modules/platforms/lxc.nix sets proxmoxLXC.privileged = false, so the image assumes it's running unprivileged. Real mismatch -- now passes --unprivileged 1 explicitly. 2. The actual root cause of the garbled console: modern (v247+) systemd routinely uses nested user namespaces and credential mounts (even plain getty units, via LoadCredential=-style mechanisms), which AppArmor's default LXC confinement denies without --features nesting=1,keyctl=1. Confirmed via the host's kernel audit log: every getty unit was crash-looping on a denied /run/credentials/* mount every ~3s, and core services like nsncd failed userns_create the same way -- the system never finished activating. Fixed live (pct set + restart on the running test container) before committing the script change: systemctl is-system-running went from never completing to "running" with zero failed units. 3. --memory doesn't touch swap -- confirmed live it silently stayed at Proxmox's own 512M default with --memory 2048. Now defaults --swap to whatever --memory resolves to. docs/auto-installer.md's manual pct create walkthrough gets the same fixes, with the "why" for each flag, since a human following it by hand would hit the identical bugs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01La55Nsss8jZ7ZuzUV9mfot
This commit is contained in:
+24
-2
@@ -45,15 +45,37 @@ of its own:
|
||||
|
||||
```sh
|
||||
pct create <vmid> local:vztmpl/<file>.tar.xz \
|
||||
--rootfs local-lvm:8 --hostname <name> --cores 2 --memory 2048 \
|
||||
--unprivileged 1 --features nesting=1,keyctl=1 \
|
||||
--rootfs local-lvm:8 --hostname <name> --cores 2 --memory 2048 --swap 2048 \
|
||||
--net0 name=eth0,bridge=vmbr0,ip=dhcp
|
||||
pct start <vmid>
|
||||
```
|
||||
|
||||
Every one of those extra flags is load-bearing, confirmed by actually
|
||||
booting one:
|
||||
|
||||
- `--unprivileged 1` — `modules/platforms/lxc.nix` sets
|
||||
`proxmoxLXC.privileged = false`, so the image assumes it's running
|
||||
unprivileged. `pct create`'s own CLI default for this flag is
|
||||
privileged (unlike the web UI, whose checkbox defaults the other way)
|
||||
— omit it and you get a privileged container running a NixOS config
|
||||
that assumes unprivileged, a real mismatch.
|
||||
- `--features nesting=1,keyctl=1` — required for a modern (v247+)
|
||||
systemd guest to boot unprivileged at all. Without it, AppArmor denies
|
||||
the nested user namespaces and credential mounts systemd routinely
|
||||
uses (even plain getty units) — every getty crash-loops on a denied
|
||||
`/run/credentials/*` mount every ~3s (this is what garbage on the
|
||||
console turns out to be) while core services like `nsncd` fail the
|
||||
same way, and the system never finishes activating.
|
||||
- `--swap 2048` — `--memory` doesn't touch swap; it silently stays at
|
||||
Proxmox's own 512M default otherwise. Match it to `--memory` unless
|
||||
you deliberately want otherwise.
|
||||
|
||||
First boot runs `boot.postBootCommands` (registers the Nix store DB and
|
||||
system profile) — there's no separate activation step to run yourself.
|
||||
`scripts/create-proxmox-resource.sh --type lxc --host <name>` automates all
|
||||
of this (build, host-key handling, upload, `pct create`) — see its `--help`.
|
||||
of this (build, host-key handling, upload, `pct create` with the flags
|
||||
above) — see its `--help`.
|
||||
|
||||
Host keys still need pre-seeding the same way as any other host (see "Host
|
||||
keys" below) — the sops-nix activation-vs-first-boot race is identical
|
||||
|
||||
Reference in New Issue
Block a user