When creating an unprivileged container with CentOS 6 (which will be EOL in Nov 2020 [0]) the console does not work.
The problem is mitigated by adding the --nohangup argument to the mingetty invocations during bootup (in /etc/init/tty.conf). The idea for the fix is based on the legacy template builder-scripts from lxc: https://github.com/lxc/lxc-templates/blob/master/templates/lxc-centos.in#L308 Since '/etc/init/tty.conf' is only written during container creation/restore and since it is guarded to CentOS versions < 7, the potential for regression should be rather small. Tested by creating an unprivileged and a privileged CentOS6 container and with nesting enabled and disabled for both - the console showed up in all cases with this fix. [0] https://wiki.centos.org/About/Product Signed-off-by: Stoiko Ivanov <s.iva...@proxmox.com> --- I shortly considered setting the contents of '/etc/init/tty.conf' irrespective of the existence of the file, but went with the safer route (should people have customized templates). Additionally this part of the code will probably be removed with EOL of CentOS 6 anyways. Thanks to Martin for reporting this! src/PVE/LXC/Setup/CentOS.pm | 11 ++++++++--- src/test/test-centos6-001/etc/init/tty.conf.exp | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/PVE/LXC/Setup/CentOS.pm b/src/PVE/LXC/Setup/CentOS.pm index d73c0cf..1e6894b 100644 --- a/src/PVE/LXC/Setup/CentOS.pm +++ b/src/PVE/LXC/Setup/CentOS.pm @@ -46,7 +46,7 @@ stop on runlevel [S016] respawn instance \$TTY -exec /sbin/mingetty \$TTY +exec /sbin/mingetty --nohangup \$TTY usage 'tty TTY=/dev/ttyX - where X is console id' __EOD__ @@ -88,8 +88,13 @@ sub template_fixup { $self->ct_make_path('/etc/init'); my $filename = "/etc/init/tty.conf"; - $self->ct_file_set_contents($filename, $tty_conf) - if ! $self->ct_file_exists($filename); + if ($self->ct_file_exists($filename)) { + my $data = $self->ct_file_get_contents($filename); + $data =~ s|^(exec /sbin/mingetty)(?!.*--nohangup) (.*)$|$1 --nohangup $2|gm; + $self->ct_file_set_contents($filename, $data); + } else { + $self->ct_file_set_contents($filename, $tty_conf); + } $filename = "/etc/init/start-ttys.conf"; $self->ct_file_set_contents($filename, $start_ttys_conf) diff --git a/src/test/test-centos6-001/etc/init/tty.conf.exp b/src/test/test-centos6-001/etc/init/tty.conf.exp index 5dcd7ad..efad240 100644 --- a/src/test/test-centos6-001/etc/init/tty.conf.exp +++ b/src/test/test-centos6-001/etc/init/tty.conf.exp @@ -9,5 +9,5 @@ stop on runlevel [S016] respawn instance $TTY -exec /sbin/mingetty $TTY +exec /sbin/mingetty --nohangup $TTY usage 'tty TTY=/dev/ttyX - where X is console id' -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel