]> www.opopop.net Git - reminder/blob - getting_boot_messages_through_a_serial_line.mdwn
attachment upload
[reminder] / getting_boot_messages_through_a_serial_line.mdwn
1 This is a howto about booting Linux without a
2 traditional screen and through a serial line.
3
4 It is often the only method for servers. But it can be generally
5 useful for debugging, by allowing logging of the boot messages, which
6 scroll too fast on a VGA screen and are not fully kept in
7 /var/log/messages.
8
9 The method is unlikely to be useful for out of the box modern
10 desktops/laptops/notebooks, as there have no more a serial
11 port. Emulation of a serial port through USB can't work here, as we
12 are too early in the boot process. In that case, and if your hardware
13 allows, you will have to plug in some serial port extension card.
14
15 I will in the following limit the scope to what I use: the IA-32
16 and derived architectures, but any information about other ones is
17 welcome.
18
19 # Controlling boot through the serial line 
20
21 ## Serial line configuration at the booting computer side
22
23 To have a complete boot experience through the serial line, you have to:
24
25 1. manage to get the BIOS I/O go through the serial line
26 1. configure a bootloader like GRUB to use the serial line
27 1. configure the kernel to output boot messages to the serial line
28 1. get a login prompt on the serial line
29
30 ### Manage to get the BIOS I/O go through the serial line
31
32 On servers it may be the only method, but it is unlikely to exist on a
33 desktop BIOS. In that case, you will miss the BIOS messages on the
34 serial line.
35
36 ### Configure a bootloader like GRUB to use the serial line
37
38 On GRUB 1 or GRUB 2 you simply have to add these lines in the
39 GRUB configuration file:
40
41     # insmod is GRUB 2 specific, comment out for GRUB 1
42     insmod serial
43     serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
44     terminal serial
45
46 ### Configure the kernel to output boot messages to the serial line
47
48 To get kernel messages on the serial line, you have to add a
49 new option to the kernel command line, like:
50
51     console=ttyS0,9600n8
52
53 which means 9600 bauds, no parity and 8 bits, to fit the previous
54 section 4 lines. This will also involve editing GRUB configuration
55 file. It may be unnecessary to do that if you use a server without a
56 VGA card, Linux is clever enough to try a serial port in that case.
57
58 If you are using Debian, you can configure items 2 and 3 the Debian
59 way, see for instance:
60 [[http://linux.xvx.cz/2009/08/debian-with-grub2-and-serial-connection/]]
61
62 Notice that you can't use arrows to navigate the GRUB menus when on
63 serial line, other standard keys are offered to that effect on the
64 greeting page.
65
66 ### Get a login prompt on the serial line
67
68 It is covered in that  page: [[recovering_when_locked_out_from_your_computer]].
69
70 ## The other end of the serial line: hardware terminal or emulation
71
72 In any case, you will need a [null modem](http://www.lammertbies.nl/comm/info/RS-232_null_modem.html) to link the
73 booting host and the terminal (real dumb serial terminal or computer
74 running an emulator).
75
76 Even if your computer emulating a terminal has no serial port, you can
77 use an USB port with a hardware adapter and a Linux driver, look
78 here: [[recovering_when_locked_out_from_your_computer]]. 
79
80 # Recording the boot messages
81
82 At that point, you should be able to get boot messages through the
83 serial line and then a login prompt. 
84
85 When you boot through a traditional VGA screen, you can only study
86 back at most aroung 50 lines, depending on screen definition. While
87 through an emulated serial terminal, you are free to record the full
88 booting process.
89
90 Minicom (see:
91 [[recovering_when_locked_out_from_your_computer]]) can record what is sent/received on the serial line, see
92 option "Capture on/off" in the menu, it has hotkey L. 
93
94 But other tools are more convenient. I suggest you use ttyrec. To
95 register in file ttyrecord what happens during a minicom session, run:
96
97     ttyrec -e minicom
98
99 When you are done with minicom, you can replay the session with:
100
101     ttyplay ttyrecord
102
103 To stop replay at some point, hit Ctrl-S; to resume hit Ctrl-Q. See
104 ttyrec man page for how to tune the general speed of the replay.
105