146 lines · plain
1.. _serial_console:2 3Linux Serial Console4====================5 6To use a serial port as console you need to compile the support into your7kernel - by default it is not compiled in. For PC style serial ports8it's the config option next to menu option:9 10:menuselection:`Character devices --> Serial drivers --> 8250/16550 and compatible serial support --> Console on 8250/16550 and compatible serial port`11 12You must compile serial support into the kernel and not as a module.13 14It is possible to specify multiple devices for console output. You can15define a new kernel command line option to select which device(s) to16use for console output.17 18The format of this option is::19 20 console=device,options21 22 device: tty0 for the foreground virtual console23 ttyX for any other virtual console24 ttySx for a serial port25 lp0 for the first parallel port26 ttyUSB0 for the first USB serial device27 28 options: depend on the driver. For the serial port this29 defines the baudrate/parity/bits/flow control of30 the port, in the format BBBBPNF, where BBBB is the31 speed, P is parity (n/o/e), N is number of bits,32 and F is flow control ('r' for RTS). Default is33 9600n8. The maximum baudrate is 115200.34 35You can specify multiple console= options on the kernel command line.36 37The behavior is well defined when each device type is mentioned only once.38In this case, the output will appear on all requested consoles. And39the last device will be used when you open ``/dev/console``.40So, for example::41 42 console=ttyS1,9600 console=tty043 44defines that opening ``/dev/console`` will get you the current foreground45virtual console, and kernel messages will appear on both the VGA46console and the 2nd serial port (ttyS1 or COM2) at 9600 baud.47 48The behavior is more complicated when the same device type is defined more49times. In this case, there are the following two rules:50 511. The output will appear only on the first device of each defined type.52 532. ``/dev/console`` will be associated with the first registered device.54 Where the registration order depends on how kernel initializes various55 subsystems.56 57 This rule is used also when the last console= parameter is not used58 for other reasons. For example, because of a typo or because59 the hardware is not available.60 61The result might be surprising. For example, the following two command62lines have the same result::63 64 console=ttyS1,9600 console=tty0 console=tty165 console=tty0 console=ttyS1,9600 console=tty166 67The kernel messages are printed only on ``tty0`` and ``ttyS1``. And68``/dev/console`` gets associated with ``tty0``. It is because kernel69tries to register graphical consoles before serial ones. It does it70because of the default behavior when no console device is specified,71see below.72 73Note that the last ``console=tty1`` parameter still makes a difference.74The kernel command line is used also by systemd. It would use the last75defined ``tty1`` as the login console.76 77If no console device is specified, the first device found capable of78acting as a system console will be used. At this time, the system79first looks for a VGA card and then for a serial port. So if you don't80have a VGA card in your system the first serial port will automatically81become the console.82 83You will need to create a new device to use ``/dev/console``. The official84``/dev/console`` is now character device 5,1.85 86(You can also use a network device as a console. See87``Documentation/networking/netconsole.rst`` for information on that.)88 89Here's an example that will use ``/dev/ttyS1`` (COM2) as the console.90Replace the sample values as needed.91 921. Create ``/dev/console`` (real console) and ``/dev/tty0`` (master virtual93 console)::94 95 cd /dev96 rm -f console tty097 mknod -m 622 console c 5 198 mknod -m 622 tty0 c 4 099 1002. LILO can also take input from a serial device. This is a very101 useful option. To tell LILO to use the serial port:102 In lilo.conf (global section)::103 104 serial = 1,9600n8 (ttyS1, 9600 bd, no parity, 8 bits)105 1063. Adjust to kernel flags for the new kernel,107 again in lilo.conf (kernel section)::108 109 append = "console=ttyS1,9600"110 1114. Make sure a getty runs on the serial port so that you can login to112 it once the system is done booting. This is done by adding a line113 like this to ``/etc/inittab`` (exact syntax depends on your getty)::114 115 S1:23:respawn:/sbin/getty -L ttyS1 9600 vt100116 1175. Init and ``/etc/ioctl.save``118 119 Sysvinit remembers its stty settings in a file in ``/etc``, called120 ``/etc/ioctl.save``. REMOVE THIS FILE before using the serial121 console for the first time, because otherwise init will probably122 set the baudrate to 38400 (baudrate of the virtual console).123 1246. ``/dev/console`` and X125 Programs that want to do something with the virtual console usually126 open ``/dev/console``. If you have created the new ``/dev/console`` device,127 and your console is NOT the virtual console some programs will fail.128 Those are programs that want to access the VT interface, and use129 ``/dev/console instead of /dev/tty0``. Some of those programs are::130 131 Xfree86, svgalib, gpm, SVGATextMode132 133 It should be fixed in modern versions of these programs though.134 135 Note that if you boot without a ``console=`` option (or with136 ``console=/dev/tty0``), ``/dev/console`` is the same as ``/dev/tty0``.137 In that case everything will still work.138 1397. Thanks140 141 Thanks to Geert Uytterhoeven <geert@linux-m68k.org>142 for porting the patches from 2.1.4x to 2.1.6x for taking care of143 the integration of these patches into m68k, ppc and alpha.144 145Miquel van Smoorenburg <miquels@cistron.nl>, 11-Jun-2000146