Removing persistent boot messages for a silent boot

I’m trying to setup a silent boot sequence: I want to go straight from systemd-boot prompt to a login prompt with no intervening text.

Here’s are the relevant lines of /etc/nixos/configuration.nix:

{
  # ...
  # Configure booting.
  boot = {
    # Stay up-to-date on the kernel.
    kernelPackages = pkgs.linuxPackages_latest;
    loader = {
      systemd-boot.editor = false;
      # Use the systemd-boot EFI boot loader.
      systemd-boot.enable = true;
      efi.canTouchEfiVariables = true;
    };
    # Silent Boot
    # https://wiki.archlinux.org/title/Silent_boot
    kernelParams = [
      "quiet"
      "splash"
      "vga=current"
      "rd.systemd.show_status=false"
      "rd.udev.log_level=3"
      "udev.log_priority=3"
    ];
    consoleLogLevel = 0;
    # https://github.com/NixOS/nixpkgs/pull/108294
    initrd.verbose = false;
  };

Also relevant:

$ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 5.13.13, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.15`
 - channels(rule): `"home-manager, nixos-21.11pre312125.21c937f8cb1"`
 - channels(root): `"nixos-21.11pre312335.8d8a28b47b7"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

With this configuration, I see these lines during boot:

setfont: KDFONTOP: Function not implemented
checking /dev/disk/by-uuid/06ec4e80-17e2-4a26-abc6-f829b36aac96...
fsck (busybox 1.33.1)
[fsck.ext4 (1) -- /mnt/root/] fsck.ext4 -a /dev/disk/by-uuid/06ec4e80-17e2-4a26-
nixos: clean, 2763324/61956096 files, 21927677/247822080 blocks

<<< NixOS Stage 2 >>>

running activation script...
setting up /etc...
starting systemd...

The first five lines look like they occur inside the initrd/initramfs (apparently, it’s an initramfs called initrd).

The Stage 2 lines are a bit of a surprise, because I have boot.initrd.verbse = false;, but that was added by nixpkgs #108294 and silences NixOS Stage 1, but seemingly not Stage 2.

I’d prefer not to use Plymouth. I tried it, but for some reason, it didn’t appear during boot and was causing my system to hang during shutdown.

Any ideas for silencing either of these blocks of text?

Thanks!

P.S. These blocks of text disappear and reappear a couple times during the boot sequence and change size as they do so. I might be more willing to allow a non-silent boot sequence if messages stayed on screen throughout, so ideas to eliminate that issue are also welcome :slight_smile:

1 Like

Stage 2 indeed still seems to use echo: https://github.com/NixOS/nixpkgs/blob/126362784184c0b341a5297c7cddffb1d2873d9d/nixos/modules/system/boot/stage-2-init.sh#L24.

I guess all the people in https://github.com/NixOS/nixpkgs/issues/32555 are just using local fixes, and for some reason nobody thought to do what they did for stage 1 for stage 2? I think the best way to get this fixed is to reply to that issue to double check that was missed, and then just implement the stage 1 fixes there - it should be straightforward as far as init changes go.

As for the other two topics…

Plymouth is cool and I recommend it! The reason it’s not appearing likely is going to be related to your kernel and graphics driver configuration, if you can share that maybe we’ll find a fix. Hanging on shutdown is likely not Plymouth, you can press escape at any point to see “behind” the graphical screen and check what is actually causing issues (systemd will probably be shutting something down).

Plymouth currently isn’t perfect on nixos, there are a handful of open tickets on making it work better with systemd, and also adding support for LUKS passwords, but those will be fixed one day and Plymouth is the actual answer to boot flickering on other distros, so if you care about the boot screens that is likely what you want eventually :slight_smile:

As for the changing resolution; this is probably caused by a few things. In early boot, your computer operates in a different mode since graphics will be handled entirely by the motherboard firmware, which often runs in lower resolutions. It’s worth checking for firmware updates or BIOS settings.

If you can’t increase your resolution there, grub can also set a different mode: boot.loader.grub.gfxmodeEfi. It would hand over to your stage 1 in the correct mode. However, note that this mode must be present in grub’s videoinfo. Don’t forget to rebuild the boot loader.

Finally, any additional flickering is likely caused by your graphics driver and/or lack of early modeset. This is especially common with nvidia, who don’t support modesetting (sigh… I should not buy their cards). There’s an option to enable modesetting with nvidia, and it should also in theory be possible to load the graphics driver in the initramfs - this should get rid of any additional flickering because the graphics driver will not need to hand anything over, at a cost of slower boots because of the bigger initramfs (also perhaps you’ll want a bigger /boot).

4 Likes

Wow - thanks for the detailed response, @TLATER!

Just for context, I’m configuring a 9th Generation Lenovo X1 Carbon Thinkpad with a 14" 3840 x 2400 display.

Ooh, fun - I haven’t contributed before, but #108294 looks simple enough.

What information would be helpful here?

Here are some of the config options related to kernel & graphics:

{
  # ...
  boot = {
    initrd = {
      availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ];
      kernelModules = [ ];
    };
    kernelModules = [ "kvm-intel" ];
    extraModulePackages = [ ];
  };

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  # Setup the system console.
  console = {
    # Make fonts readable from the start of boot
    earlySetup = true;
    font = "${pkgs.terminus_font}/share/consolefonts/ter-132n.psf.gz";
    packages = with pkgs; [ terminus_font ];
    keyMap = "us";
  };

  services.xserver = {
    # Enable a windowing system.
    enable = true;
    displayManager.startx.enable = true;
    # Configure keymap
    layout = "us";
    # Enable touchpad support (enabled default in most desktopManager).
    libinput.enable = true;
    # video support
    videoDrivers = [ "modesetting" ];
    useGlamor = true;
    # HiDPI
    dpi = 323;
  };

  # Additional hardware configuration
  hardware = {
    video.hidpi.enable = lib.mkDefault true;
    # Update the Intel microcode.
    cpu.intel.updateMicrocode = true;
    # Allow connected display discovery.
    i2c.enable = true;
    # Setup graphics acceleration.
    opengl = {
      enable = true;
      driSupport = true;
      extraPackages = with pkgs; [
        intel-compute-runtime
        intel-media-driver
        vaapiIntel
        vaapiVdpau
        libvdpau-va-gl
      ];
    };
  };
  # ...
}

and

$ lsmod | grep video
uvcvideo              114688  0
videobuf2_vmalloc      20480  1 uvcvideo
videobuf2_memops       20480  1 videobuf2_vmalloc
videobuf2_v4l2         28672  1 uvcvideo
videobuf2_common       61440  4 videobuf2_vmalloc,videobuf2_v4l2,uvcvideo,videobuf2_memops
videodev              237568  3 videobuf2_v4l2,uvcvideo,videobuf2_common
mc                     53248  4 videodev,videobuf2_v4l2,uvcvideo,videobuf2_common
video                  53248  2 thinkpad_acpi,i915
backlight              20480  4 video,thinkpad_acpi,i915,drm
i2c_core               86016  13 i2c_designware_platform,videodev,i2c_hid,i2c_designware_core,drm_kms_helper,i2c_algo_bit,i2c_smbus,i2c_i801,i2c_hid_acpi,i915,psmouse,i2c_dev,drm
usbcore               278528  5 xhci_hcd,typec,uvcvideo,btusb,xhci_pci
usb_common             16384  3 xhci_hcd,usbcore,uvcvideo

Thanks - I re-enabled Plymouth. Here’s what I see:

  • during boot
    • I see neither spinner nor NixOS logo
    • If I don’t hit any keys, a single line prints to the screen:
      setfont: KDFONTOP: Function not implemented
      
    • If I hit Esc, then ^[ prints to the screen. It does not drop “behind” the graphical screen. Each press of Esc prints another ^[. I do not see the setfont line.
  • during shutdown
    • I see both spinner and NixOS logo
    • If I don’t hit any keys, the spinner spins smoothly for a few seconds, the screen flickers to black and then back the splash screen, and the spinner freezes, updates every 5 seconds or so, and shutdown takes an extra 15-20 seconds.
    • If I hit Esc, I see “behind” the screen and shutdown finishes in about 5 seconds.

Okay, I’ve looked through the BIOS and didn’t see anything that looked relevant, other than the amount of memory allocated to graphics. It’s currently set at 256MB but I boosted it to the maximum 512MB.

I set services.fwupd.enable = true and following Problem using fwupd ran sudo fwupdmgr update. It reported:

$ sudo fwupdmgr update
Devices with no available firmware updates:
 • KXG6AZNV1T02 TOSHIBA
 • System Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI dbx
No updatable devices

Hmm - I’m currently using systemd-boot I think (boot.loader.systemd-boot.enable = true). Would this option still apply?

I have integrated Intel Xe Graphics (TGL GT2) graphics, so nvidia thankfully isn’t the issue. If you have ideas for performing the modeset earlier for Intel Mesa, let me know!

On a mildly unrelated side note, you can save yourself some effort by including the nixos-hardware module for your system: https://github.com/NixOS/nixos-hardware/tree/master/lenovo/thinkpad/x1

It includes a handful of those settings already, as well as what I will recommend for enabling early modesetting :wink:

I wonder if your console settings are messing with plymouth. Can you remove the earlySetup from that, or perhaps the whole block while testing for now?

But there are no logs being shown that would indicate why things take so long? No message from systemd saying that it is shutting down some long-running service? 5 minutes is exactly the time-out time.

This is probably unnecessary, I’d keep it at the default. It’s just worth checking, especially on laptops, since you’d think they are properly configured to use the screens they were designed for, wouldn’t you? I suppose it’s sometimes not for integrated GPUs with high resolution screens, though, as in this case.

Erm, whoops, I thought for sure you were using grub, not sure how I got that idea. With systemd-boot you want boot.loader.systemd-boot.consoleMode

I think enabling early modesetting with intel is simply adding i915 to boot.initrd.kernelModules. As mentioned earlier, the nixos-hardware module for your device already does that, so I’d highly recommend just importing that - it’ll keep you up with future fixes.

This might also fix plymouth - it requires early modesetting, if I recall correctly, so it’s possible you’re only seeing its text type interface (that you have skillfully made empty) before shut down time.

Ack - sorry that this has been radio silent for the last couple of weeks. Nearly all my personal time has gone into some short-term family commitments. Once they resolve, I’ll be back at this :slight_smile:

I have attention to devote to this issue again.

Done - I’ve added the nixos-hardware channel and activated the x1 module.

Okay - I commented out the console block.

Done - reset to 256MB.

Oh, great - I’ve set that to auto.

I’ve added i915 to boot.initrd.kernelModules.

After all these changes, I ran both sudo nixos-rebuild switch and, after rebooting, home-manager switch.

After those changes, here’s the current situation:

  • Adding boot.loader.systemd-boot.consoleMode = auto and removing console.font = "ter-132n" means the console font is now very small. This is an easy fix.
  • On boot, here’s the sequence of events (about 20 seconds total)
    1. the BIOS splash screen appears normally with a Lenovo logo and message for interrupting the start sequence (~5 seconds)
    2. the boot selection menu appears with very small font (~5 seconds)
    3. blank screen (~1 second)
    4. the BIOS screen with the Lenovo logo (less than 1/2 second)
    5. blank screen (less than 1/2 second)
    6. a screen showing the text “setfont: KDFONTOP: Function not implemented” (less than 1/2 second)
    7. the expected Plymouth boot screen: the Lenovo logo with a small spinner beneath it (~2 seconds).
    8. the screen showing “setfont: KDFONTOP: Function not implemented” (~4 seconds)
    9. the Linux console ready for login.
  • On shutdown, here’s the sequence of events
    1. Combination of BIOS splash screen and Plymouth spinner appears. I see the Lenovo logo, the NixOS snowflake, and a Plymouth spinner (2-5 seconds).
    2. blank screen (1-2 seconds).
    3. the Lenovo logo, NixOS snowflake, and Plymouth spinner, but the spinner no longer spins (10-20 seconds).
    4. Shutdown completes.

Right - if I hit Esc quickly during shutdown - that is, before the splash screen flickers and freezes - I can see the console messages, but they pass quickly. The shutdown sequence happens quickly and seamlessly (5 seconds or so).

If I don’t hit Esc, then Plymouth flickers from a spinner to a black screen, then back to the spinner. But now, the spinner freezes and Esc has no effect. Hitting it doesn’t bring up the console. Also, shutdown goes from 5 seconds to maybe 25 seconds (I paid closer attention - either something changed or my initial estimate of several minutes was exaggerated). It’s less than the 5 minute timeout but noticeably more than the 5 seconds it takes otherwise.