Why LXC containers default to 2 TTYs

rosy

New Member
Oct 27, 2024
1
0
1
I just noticed that in the default configuration of newly created LXC container, the TTY count defaults to 2.

I changed it to 1 and nothing bad happens :p. Using web console and pct enter simultaneously doesn't break either.

Just curious why it defaults to 2, I thought there might be a reason.
 
The reason LXC containers use tty2 instead of tty1 by default is related to how init systems (such as systemd) manage terminals inside the container.

Explanation:​

  1. Systemd reserves tty1
    • On systems using systemd, tty1 is typically reserved for the primary login interface during boot or for system messages.
    • Inside a container, tty1 may be unavailable because there isn't a full "boot" process like on a physical machine.
  2. Avoids conflicts with system logs
    • Some distributions send kernel and init system logs to tty1, which could interfere with interactive terminal usage inside the container.
  3. Compatibility with various systems
    • tty2 is considered a "safer" choice for the first available interactive terminal.
    • LXC simply skips tty1 to avoid potential issues across different Linux distributions.
 
  • Like
Reactions: LnxBil