0001 .. _serial_console:
0002
0003 Linux Serial Console
0004 ====================
0005
0006 To use a serial port as console you need to compile the support into your
0007 kernel - by default it is not compiled in. For PC style serial ports
0008 it's the config option next to menu option:
0009
0010 :menuselection:`Character devices --> Serial drivers --> 8250/16550 and compatible serial support --> Console on 8250/16550 and compatible serial port`
0011
0012 You must compile serial support into the kernel and not as a module.
0013
0014 It is possible to specify multiple devices for console output. You can
0015 define a new kernel command line option to select which device(s) to
0016 use for console output.
0017
0018 The format of this option is::
0019
0020 console=device,options
0021
0022 device: tty0 for the foreground virtual console
0023 ttyX for any other virtual console
0024 ttySx for a serial port
0025 lp0 for the first parallel port
0026 ttyUSB0 for the first USB serial device
0027
0028 options: depend on the driver. For the serial port this
0029 defines the baudrate/parity/bits/flow control of
0030 the port, in the format BBBBPNF, where BBBB is the
0031 speed, P is parity (n/o/e), N is number of bits,
0032 and F is flow control ('r' for RTS). Default is
0033 9600n8. The maximum baudrate is 115200.
0034
0035 You can specify multiple console= options on the kernel command line.
0036 Output will appear on all of them. The last device will be used when
0037 you open ``/dev/console``. So, for example::
0038
0039 console=ttyS1,9600 console=tty0
0040
0041 defines that opening ``/dev/console`` will get you the current foreground
0042 virtual console, and kernel messages will appear on both the VGA
0043 console and the 2nd serial port (ttyS1 or COM2) at 9600 baud.
0044
0045 Note that you can only define one console per device type (serial, video).
0046
0047 If no console device is specified, the first device found capable of
0048 acting as a system console will be used. At this time, the system
0049 first looks for a VGA card and then for a serial port. So if you don't
0050 have a VGA card in your system the first serial port will automatically
0051 become the console.
0052
0053 You will need to create a new device to use ``/dev/console``. The official
0054 ``/dev/console`` is now character device 5,1.
0055
0056 (You can also use a network device as a console. See
0057 ``Documentation/networking/netconsole.rst`` for information on that.)
0058
0059 Here's an example that will use ``/dev/ttyS1`` (COM2) as the console.
0060 Replace the sample values as needed.
0061
0062 1. Create ``/dev/console`` (real console) and ``/dev/tty0`` (master virtual
0063 console)::
0064
0065 cd /dev
0066 rm -f console tty0
0067 mknod -m 622 console c 5 1
0068 mknod -m 622 tty0 c 4 0
0069
0070 2. LILO can also take input from a serial device. This is a very
0071 useful option. To tell LILO to use the serial port:
0072 In lilo.conf (global section)::
0073
0074 serial = 1,9600n8 (ttyS1, 9600 bd, no parity, 8 bits)
0075
0076 3. Adjust to kernel flags for the new kernel,
0077 again in lilo.conf (kernel section)::
0078
0079 append = "console=ttyS1,9600"
0080
0081 4. Make sure a getty runs on the serial port so that you can login to
0082 it once the system is done booting. This is done by adding a line
0083 like this to ``/etc/inittab`` (exact syntax depends on your getty)::
0084
0085 S1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
0086
0087 5. Init and ``/etc/ioctl.save``
0088
0089 Sysvinit remembers its stty settings in a file in ``/etc``, called
0090 ``/etc/ioctl.save``. REMOVE THIS FILE before using the serial
0091 console for the first time, because otherwise init will probably
0092 set the baudrate to 38400 (baudrate of the virtual console).
0093
0094 6. ``/dev/console`` and X
0095 Programs that want to do something with the virtual console usually
0096 open ``/dev/console``. If you have created the new ``/dev/console`` device,
0097 and your console is NOT the virtual console some programs will fail.
0098 Those are programs that want to access the VT interface, and use
0099 ``/dev/console instead of /dev/tty0``. Some of those programs are::
0100
0101 Xfree86, svgalib, gpm, SVGATextMode
0102
0103 It should be fixed in modern versions of these programs though.
0104
0105 Note that if you boot without a ``console=`` option (or with
0106 ``console=/dev/tty0``), ``/dev/console`` is the same as ``/dev/tty0``.
0107 In that case everything will still work.
0108
0109 7. Thanks
0110
0111 Thanks to Geert Uytterhoeven <geert@linux-m68k.org>
0112 for porting the patches from 2.1.4x to 2.1.6x for taking care of
0113 the integration of these patches into m68k, ppc and alpha.
0114
0115 Miquel van Smoorenburg <miquels@cistron.nl>, 11-Jun-2000