Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch linux kernel console after boot process?

On my embedded system I usually use /dev/ttyS0 as a main console. This is achieved by passing kernel parameter console=/dev/ttyS0 and when init takes its part, getty is fired on the same device as specified in inittab by eg. ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100.

Is there any possibility to change these settings without restart and switch the console to another terminal like ttyS1, ttyUSBx or even some pseudo tty?

like image 662
Honza Avatar asked May 30 '13 06:05

Honza


People also ask

How do I enable serial console in Linux?

To enable the serial console for your custom Linux VM image, enable console access in the file /etc/inittab to run a terminal on ttyS0 . For example: S0:12345:respawn:/sbin/agetty -L 115200 console vt102 . You may also need to spawn a getty on ttyS0. This can be done with systemctl start [email protected] .

What is Linux serial console?

Linux serial console is a console implementation via serial port, enabled by option CONFIG_SERIAL_CONSOLE in the kernel configuration. It may be used in some embedded systems, and on servers, where a direct interaction with operator is not expected.

What is ttyS0?

ttyS0 is the device for the first UART serial port on x86 and x86_64 architectures. If you have a PC motherboard with serial ports you'd be using a ttySn to attach a modem or a serial console. ttyUSB0 is the device for the first USB serial convertor.


1 Answers

It seems that perhaps you don't actually want the console log messages on another device, but are only proposing to redirect them there to stop them from interfering with binary transfers on the primary serial device.

If that is the case, you may be able to solve your problem by dynamically adjusting the console log level.

http://tuxthink.blogspot.com/2012/07/printk-and-console-log-level.html

Suggests that you can do this by writing to a proc node:

echo "6" > /proc/sys/kernel/printk

Would set it to 6 in their example. I suspect setting it to 0 or 1 would work for your purposes - if something goes that wrong, your binary transfer is probably failed anyway.

Log entries should still be retrievable by dmesg regardless of this setting.

like image 91
Chris Stratton Avatar answered Oct 22 '22 01:10

Chris Stratton