From: Daan De Meyer Date: Sun, 30 Apr 2023 15:07:01 +0000 (+0200) Subject: Switch back to using ttyS0 as the default serial console X-Git-Tag: v15~188^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2893ca9777e6a209c14a01957fc482d21aea0e44;p=thirdparty%2Fmkosi.git Switch back to using ttyS0 as the default serial console virtio_console is not always a builtin kernel module on all the distributions we support. This means that the kernel can only start logging to it after the initramfs has been unpacked and the virtio_console module has been loaded from it. Any message that's logged to kmsg before that dissapears into the void which makes debugging boot failures rather difficult. Instead, until systemd-stub is recent enough in all supported distros to receive extra kernel cmdline arguments via smbios, let's use a default kernel cmdline of "console=ttyS0" so that the serial console works by default but can still be overridden by users. --- diff --git a/.github/mkosi.conf.d/10-common.conf b/.github/mkosi.conf.d/10-common.conf index f8e66bed5..6d34d64ba 100644 --- a/.github/mkosi.conf.d/10-common.conf +++ b/.github/mkosi.conf.d/10-common.conf @@ -1,7 +1,6 @@ [Output] CacheDirectory=mkosi.cache -KernelCommandLine=console=hvc0 - systemd.unit=mkosi-check-and-shutdown.service +KernelCommandLine=systemd.unit=mkosi-check-and-shutdown.service systemd.log_target=console systemd.default_standard_output=journal+console diff --git a/mkosi.md b/mkosi.md index 1f64a4927..356b94649 100644 --- a/mkosi.md +++ b/mkosi.md @@ -729,7 +729,7 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0", `Autologin=`, `--autologin` : Enable autologin for the `root` user on `/dev/pts/0` (nspawn), - `/dev/tty1` and `/dev/hvc0`. + `/dev/tty1` and `/dev/ttyS0`. `BuildScript=`, `--build-script=` diff --git a/mkosi/__init__.py b/mkosi/__init__.py index f32813e8f..ff923da46 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -363,8 +363,6 @@ def configure_autologin(state: MkosiState) -> None: "mkosi.resources", "console_getty_autologin.conf") add_dropin_config_from_resource(state.root, "serial-getty@ttyS0.service", "autologin", "mkosi.resources", "serial_getty_autologin.conf") - add_dropin_config_from_resource(state.root, "serial-getty@hvc0.service", "autologin", - "mkosi.resources", "serial_getty_autologin.conf") add_dropin_config_from_resource(state.root, "getty@tty1.service", "autologin", "mkosi.resources", "getty_autologin.conf") @@ -1934,14 +1932,8 @@ def run_qemu(args: MkosiArgs, config: MkosiConfig) -> None: "-nographic", "-nodefaults", "-chardev", "stdio,mux=on,id=console,signal=off", - # Use virtconsole which appears as /dev/hvc0 in the guest on which a getty is automatically - # by spawned by systemd without needing a console= cmdline argument. - "-device", "virtio-serial", - "-device", "virtconsole,chardev=console", - "-mon", "console", - # EDK2 doesn't support virtio-serial, so add a regular serial console as well to get bootloader - # output. "-serial", "chardev:console", + "-mon", "console", ] for k, v in config.credentials.items(): diff --git a/mkosi/config.py b/mkosi/config.py index ec26dd5ca..cf249d01c 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -755,6 +755,7 @@ class MkosiConfigParser: dest="kernel_command_line", section="Output", parse=config_make_list_parser(delimiter=" "), + default=["console=ttyS0"], ), MkosiConfigSetting( dest="secure_boot", @@ -1860,13 +1861,10 @@ def load_kernel_command_line_extra(args: argparse.Namespace) -> list[str]: columns, lines = shutil.get_terminal_size() cmdline = [ - f"systemd.tty.term.hvc0={os.getenv('TERM', 'vt220')}", - f"systemd.tty.columns.hvc0={columns}", - f"systemd.tty.rows.hvc0={lines}", f"systemd.tty.term.ttyS0={os.getenv('TERM', 'vt220')}", f"systemd.tty.columns.ttyS0={columns}", f"systemd.tty.rows.ttyS0={lines}", - "console=hvc0", + "console=ttyS0", ] if args.output_format == OutputFormat.cpio: