Can't start NixOS lxc on Proxmox

I’m trying to follow the instructions in Proxmox Linux Container - NixOS Wiki for creating a Proxmox lxc running NixOS[1]. I can get pretty far in the instructions but in the end, despite the lxc starting with no errors, I can’t open a console or shell on it. I just get black. Here are my steps:

Locally:

export RELEASE=21.11
export BUILDID=166445692
mv nixos-system-x86_64-linux.tar.xz nixos-${RELEASE}-default_${BUILDID}_amd64.tar.xz

Then on my Proxmox host (after uploading the .tar.xz):

pct create $(pvesh get /cluster/nextid) \
  --description nixos-template \
  --hostname nixos-template \
  holodeck4:vztmpl/nixos-21.11-default_166445692_amd64.tar.xz \
  --arch amd64 \
  --ostype unmanaged \
  --net0 name=eth0,ip=dhcp,bridge=vmbr0,firewall=1 \
  --storage local-zfs \
  --unprivileged true \
  --features nesting=1

If I try to start this lxc it starts, but then I just get black in the console:

Things I’ve tried:

  1. Adding lxc.init.cmd: /sbin/init to the VMID.conf file
  2. privileged/unprivileged lxc
  3. nesting on and off

Anyone have an idea what I might be doing wrong?

Note: I’m on PVE 7.1-10

[1] This is part of bootstrapping my use of NixOS: by having the lxc I get access to nix-build which will help me build a custom Live CD that has my ssh key (Creating a NixOS live CD - NixOS Wiki).

Oh wow, I figured it out one second later:

The console just doesn’t render existing text, but I am at the console prompt. I can just type “root” and hit enter:

image

(I haven’t seen this issue before. Usually the previously rendered text is present when the console is loaded and I’ve just taken that for granted)

1 Like

For anyone curious, this is my final version:

pct create $(pvesh get /cluster/nextid) \
  --description nixos-template \
  --hostname nixos-template \
  holodeck4:vztmpl/nixos-21.11-default_166445692_amd64.tar.xz \
  --arch amd64 \
  --ostype unmanaged \
  --net0 name=eth0,ip=dhcp,bridge=vmbr0,firewall=1 \
  --storage local-zfs \
  --cmode console \
  --features nesting=1 \
  --unprivileged true \
  --template true

lxc.init.cmd: /sbin/init doesn’t seem necessary. It works unprivileged + nesting.

cmode console seems to fix the console. I’m not quite sure why.

2 Likes