1*4882a593Smuzhiyun.. _serial_console: 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunLinux Serial Console 4*4882a593Smuzhiyun==================== 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunTo use a serial port as console you need to compile the support into your 7*4882a593Smuzhiyunkernel - by default it is not compiled in. For PC style serial ports 8*4882a593Smuzhiyunit's the config option next to menu option: 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun:menuselection:`Character devices --> Serial drivers --> 8250/16550 and compatible serial support --> Console on 8250/16550 and compatible serial port` 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunYou must compile serial support into the kernel and not as a module. 13*4882a593Smuzhiyun 14*4882a593SmuzhiyunIt is possible to specify multiple devices for console output. You can 15*4882a593Smuzhiyundefine a new kernel command line option to select which device(s) to 16*4882a593Smuzhiyunuse for console output. 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunThe format of this option is:: 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun console=device,options 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun device: tty0 for the foreground virtual console 23*4882a593Smuzhiyun ttyX for any other virtual console 24*4882a593Smuzhiyun ttySx for a serial port 25*4882a593Smuzhiyun lp0 for the first parallel port 26*4882a593Smuzhiyun ttyUSB0 for the first USB serial device 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun options: depend on the driver. For the serial port this 29*4882a593Smuzhiyun defines the baudrate/parity/bits/flow control of 30*4882a593Smuzhiyun the port, in the format BBBBPNF, where BBBB is the 31*4882a593Smuzhiyun speed, P is parity (n/o/e), N is number of bits, 32*4882a593Smuzhiyun and F is flow control ('r' for RTS). Default is 33*4882a593Smuzhiyun 9600n8. The maximum baudrate is 115200. 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunYou can specify multiple console= options on the kernel command line. 36*4882a593SmuzhiyunOutput will appear on all of them. The last device will be used when 37*4882a593Smuzhiyunyou open ``/dev/console``. So, for example:: 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun console=ttyS1,9600 console=tty0 40*4882a593Smuzhiyun 41*4882a593Smuzhiyundefines that opening ``/dev/console`` will get you the current foreground 42*4882a593Smuzhiyunvirtual console, and kernel messages will appear on both the VGA 43*4882a593Smuzhiyunconsole and the 2nd serial port (ttyS1 or COM2) at 9600 baud. 44*4882a593Smuzhiyun 45*4882a593SmuzhiyunNote that you can only define one console per device type (serial, video). 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunIf no console device is specified, the first device found capable of 48*4882a593Smuzhiyunacting as a system console will be used. At this time, the system 49*4882a593Smuzhiyunfirst looks for a VGA card and then for a serial port. So if you don't 50*4882a593Smuzhiyunhave a VGA card in your system the first serial port will automatically 51*4882a593Smuzhiyunbecome the console. 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunYou will need to create a new device to use ``/dev/console``. The official 54*4882a593Smuzhiyun``/dev/console`` is now character device 5,1. 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun(You can also use a network device as a console. See 57*4882a593Smuzhiyun``Documentation/networking/netconsole.rst`` for information on that.) 58*4882a593Smuzhiyun 59*4882a593SmuzhiyunHere's an example that will use ``/dev/ttyS1`` (COM2) as the console. 60*4882a593SmuzhiyunReplace the sample values as needed. 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun1. Create ``/dev/console`` (real console) and ``/dev/tty0`` (master virtual 63*4882a593Smuzhiyun console):: 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun cd /dev 66*4882a593Smuzhiyun rm -f console tty0 67*4882a593Smuzhiyun mknod -m 622 console c 5 1 68*4882a593Smuzhiyun mknod -m 622 tty0 c 4 0 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun2. LILO can also take input from a serial device. This is a very 71*4882a593Smuzhiyun useful option. To tell LILO to use the serial port: 72*4882a593Smuzhiyun In lilo.conf (global section):: 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun serial = 1,9600n8 (ttyS1, 9600 bd, no parity, 8 bits) 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun3. Adjust to kernel flags for the new kernel, 77*4882a593Smuzhiyun again in lilo.conf (kernel section):: 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun append = "console=ttyS1,9600" 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun4. Make sure a getty runs on the serial port so that you can login to 82*4882a593Smuzhiyun it once the system is done booting. This is done by adding a line 83*4882a593Smuzhiyun like this to ``/etc/inittab`` (exact syntax depends on your getty):: 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun S1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun5. Init and ``/etc/ioctl.save`` 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun Sysvinit remembers its stty settings in a file in ``/etc``, called 90*4882a593Smuzhiyun ``/etc/ioctl.save``. REMOVE THIS FILE before using the serial 91*4882a593Smuzhiyun console for the first time, because otherwise init will probably 92*4882a593Smuzhiyun set the baudrate to 38400 (baudrate of the virtual console). 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun6. ``/dev/console`` and X 95*4882a593Smuzhiyun Programs that want to do something with the virtual console usually 96*4882a593Smuzhiyun open ``/dev/console``. If you have created the new ``/dev/console`` device, 97*4882a593Smuzhiyun and your console is NOT the virtual console some programs will fail. 98*4882a593Smuzhiyun Those are programs that want to access the VT interface, and use 99*4882a593Smuzhiyun ``/dev/console instead of /dev/tty0``. Some of those programs are:: 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun Xfree86, svgalib, gpm, SVGATextMode 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun It should be fixed in modern versions of these programs though. 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun Note that if you boot without a ``console=`` option (or with 106*4882a593Smuzhiyun ``console=/dev/tty0``), ``/dev/console`` is the same as ``/dev/tty0``. 107*4882a593Smuzhiyun In that case everything will still work. 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun7. Thanks 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun Thanks to Geert Uytterhoeven <geert@linux-m68k.org> 112*4882a593Smuzhiyun for porting the patches from 2.1.4x to 2.1.6x for taking care of 113*4882a593Smuzhiyun the integration of these patches into m68k, ppc and alpha. 114*4882a593Smuzhiyun 115*4882a593SmuzhiyunMiquel van Smoorenburg <miquels@cistron.nl>, 11-Jun-2000 116