Systemd – How to Get Kernel Messages on Serial Console

linux-kernelserial-consolesystemd

I'm trying to set up an A20-OLinuXino-LIME2 as a headless fileserver with a Debian 8 image from Igor Pečovnik's builds.

I would like the system to output its kernel messages to the serial console (ttyS0) during the boot process and end up with a login prompt on ttyS0.

By default, the image uses the following kernel commandline:

console=tty1 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 panic=10 consoleblank=0 enforcing=0 loglevel=1

… which of course doesn't output any kernel messages to ttyS0 — I get no output whatsoever between the U-Boot's "Uncompressing Linux... done, booting the kernel." and systemd spawning the login prompt.

I figured I just needed to replace console=tty1 with console=ttyS0,115200n8, but then systemd grabs the serial console and squelches the kernel, so I only get the bootloader messages, then systemd's "[ OK ] Started foo."-style messages, and finally the login prompt.

Is there a way to get both the kernel messages ("[ 0.000000] foo") and systemd's output on ttyS0?
Or a way to at least mute systemd so I can see the kernel messages if I ever need to debug a boot failure?


I should add that the kernel definitely supports logging to ttyS0: When I replace the entire kernel commandline with console=ttyS0,115200n8, I get the "[ 0.000000] foo" messages I want, but the kernel naturally panics because it can't find its rootfs.

Best Answer

systemd grabs the serial console and squelches the kernel, so I only get the bootloader messages

Does it? It doesn't. The loglevel=1 in your kernel command line is responsible for telling kernel to stop logging. Try removing that statement (or explicitly setting it to loglevel=7).

To stop systemd from logging its own status messages, use systemd.show_status=no (ref.: systemd(1)).


P. S.: please, guys, stop attributing arbitrary software bugs and misconfigurations to systemd.

Related Question