How to Prevent Console Screen Clearing During Linux Boot: Preserving Early Boot Messages


2 views

During Linux system initialization, the console undergoes several clearing operations that can make early boot messages disappear before you have a chance to read them. This behavior occurs because:

  • The kernel clears the screen during early initialization
  • Systemd or other init systems may clear the console before displaying the login prompt
  • Some messages appear before logging subsystems are fully initialized

The most effective way to prevent console clearing is through kernel command line parameters:

# In GRUB configuration (/etc/default/grub)
GRUB_CMDLINE_LINUX_DEFAULT="quiet consoleblank=0 loglevel=7"

Key parameters:

  • consoleblank=0 - Disables console blanking
  • loglevel=7 - Shows debug messages (adjust as needed)
  • Remove quiet if present to see more verbose output

For systems using systemd, you can modify the getty service to prevent clearing:

# Create override directory if it doesn't exist
sudo mkdir -p /etc/systemd/system/getty@.service.d/

# Create override file
sudo tee /etc/systemd/system/getty@.service.d/noclear.conf <<EOF
[Service]
TTYVTDisallocate=no
EOF

# Reload systemd
sudo systemctl daemon-reload

When preventing clearing isn't sufficient, consider capturing the output:

# Method 1: Using dmesg with timestamps
dmesg -T | grep -i "early"

# Method 2: Persistent kernel log buffer
echo "kernel.printk = 7 4 1 7" >> /etc/sysctl.conf
sysctl -p

The framebuffer console may also affect visibility:

# Disable framebuffer scrolling
echo 0 > /sys/module/vt/parameters/default_utf8
echo 0 > /sys/module/vt/parameters/vt.global_cursor_default

For a permanent fix, modify your GRUB configuration:

# Edit GRUB config
sudo nano /etc/default/grub

# Add or modify these lines:
GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0 loglevel=7"
GRUB_TERMINAL_OUTPUT="console"

# Update GRUB
sudo update-grub
  • Check all virtual consoles (Ctrl+Alt+F1 through F7)
  • Review journal logs: journalctl -b
  • Test changes in recovery mode first
  • For embedded systems, check bootloader configuration

Many Linux administrators and developers have encountered this frustrating scenario: critical kernel messages briefly appear during boot only to vanish before you can read them. These messages often contain valuable debugging information that isn't even captured in dmesg output. The most common occurrence is the screen clearing just before the login prompt appears.

The console clearing behavior is typically controlled by:

  • The Linux kernel's console driver
  • getty processes managing terminal sessions
  • Various initialization scripts that may send clear commands

The most effective way to prevent the initial clearing is through kernel boot parameters. Add this to your bootloader configuration (GRUB, systemd-boot, etc.):

consoleblank=0

This parameter sets the console blank timeout to zero, effectively disabling the automatic screen blanking feature.

To prevent clearing at the login prompt, modify getty settings. For systemd systems, create or edit:

/etc/systemd/system/getty@tty1.service.d/noclear.conf

With these contents:

[Service]
TTYVTDisallocate=no
ExecStart=
ExecStart=-/sbin/agetty --noclear %I $TERM

For comprehensive message capture, consider these alternatives:

# For GRUB bootloader:
GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0 loglevel=7 earlyprintk=vga"

# For immediate post-boot capture:
dmesg --human --color=always | less -R
journalctl -b -k --no-pager

When dealing with hardware-related messages that disappear, try:

# Increase PCI verbosity
pci=earlydump

# For USB device detection
usb-storage.delay_use=30

For development systems where you always want maximum visibility:

# /etc/default/grub modification
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash consoleblank=0 loglevel=7"
GRUB_CMDLINE_LINUX=""

# Then update GRUB
sudo update-grub

After implementing these changes, verify with:

cat /proc/cmdline
systemctl show getty@tty1.service | grep -i clear