Console not working in proxmox lxc container

I followed the guide here:
https://nixos.wiki/wiki/Proxmox_Virtual_Environment

and I am able to ssh in to the container. However, when I use the Proxmox console, I get a cursor. I can type anything I like and see my input, but it does nothing.

I’m having the exact same issues also following the wiki page you linked.

At the bottom of the wiki page you linked there’s a link to the old version of the page, Proxmox Linux Container - NixOS Wiki.

At the very bottom of that page is the below snippet

If you are still unable to get the console to render, you can try changing the console to /dev/console instead of the standard tty.

In the LXC options page, double clicking “Console mode” and changing it from “Default (tty)” to “/dev/console” and restarting the container lets me access the console as expected.

I’ve not been able to figure out why the default doesn’t work.

From debugging using the instructions in Proxmox Virtual Environment - NixOS Wiki it looks like “getty@tty1.service” in systemd is disabled using the minimal/default config.

If I create a minimal config as provided in the wiki and add console.enable = true i get the below error. No /dev/tty0 exists so the service fails to start

root@lldap:~]# systemctl status getty@tty1.service
â—‹ getty@tty1.service - Getty on tty1
     Loaded: loaded (/etc/systemd/system/getty@.service; disabled; preset: enabled)
    Drop-In: /nix/store/3n2fg3yd4m780r1l4hgqggnv9s4g1zdp-system-units/getty@.service.d
             └─overrides.conf
     Active: inactive (dead)
  Condition: start condition failed at Sun 2023-07-16 08:16:01 UTC; 1min 26s ago
             └─ ConditionPathExists=/dev/tty0 was not met
       Docs: man:agetty(8)
             man:systemd-getty-generator(8)
             http://0pointer.de/blog/projects/serial-console.html

configuration.nix:

[root@lldap:~]# systemctl status getty@tty1.service
â—‹ getty@tty1.service - Getty on tty1
     Loaded: loaded (/etc/systemd/system/getty@.service; disabled; preset: enabled)
    Drop-In: /nix/store/3n2fg3yd4m780r1l4hgqggnv9s4g1zdp-system-units/getty@.service.d
             └─overrides.conf
     Active: inactive (dead)
  Condition: start condition failed at Sun 2023-07-16 08:16:01 UTC; 4min 56s ago
             └─ ConditionPathExists=/dev/tty0 was not met
       Docs: man:agetty(8)
             man:systemd-getty-generator(8)
             http://0pointer.de/blog/projects/serial-console.html

If I do touch /dev/tty0 then systemctl start getty@tty1.service the service comes up. I can then access the console in Proxmox using the “Default (tty)”. On reboot I’ll loose access as manually need to create /dev/tty0 again and then manually start systemctl start getty@tty1.service.

For now I just use /dev/console but it’d be nice for the default proxmox option to work.

1 Like

Hi @aevans,

I’ve also tried to fix this “issue” on my Proxmox system and eventually got ones step closer with the following setting:

  console.enable = true;

  systemd.services."getty@" = {
    unitConfig.ConditionPathExists = ["" "/dev/%I"];
  };

So, back to using the default (tty) console for the LXC container. But now I see with every login via the proxmox console the following error in getty@tty1.service log:

login[36163]: pam_systemd(login:session): Failed to create session: Seat has no VTs but VT number not 0

Well, I have no idea where to go from here … but maybe someone else has one?

Did you ever get past this?

I had always used pct enter followed by /bin/sh -l, so I did not notice this issue till now. @ptweety is on the right track; agetty is masked because console is disabled by default on containers. Also, ConditionPathExists is set to /dev/tty0, which is missing inside PVE LXCs. Making those suggested changes fixed the console for me. I’m not sure what caused the Failed to create session error though. I am not able to reproduce it on PVE 8.1.4 with nixos unstable, 23.05 and 22.11.

Here’s a minimal flake to test on your own setup:

{
        description = "A very basic flake";

        inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";

        outputs = { self, nixpkgs }: let
                pve_ssh_tgt = "root@192.168.1.150";
                vmid = "9918";
        in {
                nixosConfigurations.test-lxc = nixpkgs.lib.nixosSystem {
                        system = "x86_64-linux";
                        modules = [
                                ({lib, modulesPath, pkgs, ...}: {
                                        imports = [ "${modulesPath}/virtualisation/proxmox-lxc.nix" ];
                                        console.enable = true;
                                        systemd.services."getty@".unitConfig.ConditionPathExists = [ "" "/dev/%I" ];
                                        users.users.root.initialPassword = "password";
                                })
                        ];
                };
                packages.x86_64-linux.deploy = nixpkgs.legacyPackages.x86_64-linux.writeScriptBin "deploy" ''
                        scp ${self.nixosConfigurations.test-lxc.config.system.build.tarball}/tarball/nixos-system-x86_64-linux.tar.xz ${pve_ssh_tgt}:/var/lib/vz/template/cache/
                        ssh ${pve_ssh_tgt} "pct stop ${vmid}; pct destroy ${vmid}; pct create ${vmid} local:vztmpl/nixos-system-x86_64-linux.tar.xz --hostname test --storage local-lvm --features nesting=1 && pct start ${vmid}"
                '';

        };
}

Change pve_ssh_tgt and vmid, then run nix run .#deploy. You will also have to change the scp and pct commands if you are not using local-lvm.

I’ll open a PR adding these changes to the pve lxc module.

EDIT: nixos/proxmox-lxc: fix console access by illustris · Pull Request #307163 · NixOS/nixpkgs · GitHub

1 Like