serial-console.txt 4.0 KB

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