Difference between revisions of "Working with the serial console"

From ArchWiki
Jump to: navigation, search
(Configuration)
Line 2: Line 2:
 
=Introduction=
 
=Introduction=
  
Configure your Arch Linux machine, so you can connect to it via the serial console port (com port).
+
Configure your Arch Linux machine so you can connect to it via the serial console port (com port).
This will enable you to administer the machine, even if it has no keyboard, mouse, monitor or network attached to it (a headless server).
+
This will enable you to administer the machine even if it has no keyboard, mouse, monitor, or network attached to it (a headless server).
  
 
As of Arch Linux 2007.x, installation of Arch Linux is possible via the serial console as well.
 
As of Arch Linux 2007.x, installation of Arch Linux is possible via the serial console as well.
  
A basic environment for this scenario is two machines, connected using a serial cable (9-pin connector cable).
+
A basic environment for this scenario is two machines connected using a serial cable (9-pin connector cable).
The administering machine can be any Linux or Windows machine with a terminal emulator program (putty or Minicom for example)
+
The administering machine can be any Linux or Windows machine with a terminal emulator program (PuTTY or Minicom, for example).
  
The configuration instructions below will enable grub menu selection, boot messages and terminal forwarding to the serial console.
+
The configuration instructions below will enable GRUB menu selection, boot messages, and terminal forwarding to the serial console.
  
 
=Configuration=
 
=Configuration=
Line 16: Line 16:
 
===Configure console access on the target machine===
 
===Configure console access on the target machine===
  
1. Edit the grub.conf file:
+
1. Edit the GRUB config file:
  
<pre>
+
vi /boot/grub/menu.lst
# vi /boot/grub/menu.lst
+
</pre>
+
  
 
Add these lines to the general area of the configuration:
 
Add these lines to the general area of the configuration:
  
<pre>
+
{{ic|<nowiki>
serial --unit=0 --speed=9600
+
serial --unit=0 --speed=9600</nowiki><br>
terminal --timeout=5 serial console
+
<nowiki>terminal --timeout=5 serial console</nowiki>
</pre>
+
}}
  
 
Add the console parameters at the end of your current kernel line:
 
Add the console parameters at the end of your current kernel line:
  
<pre>
+
{{ic|<nowiki>
 
console=tty0 console=ttyS0,9600
 
console=tty0 console=ttyS0,9600
</pre>
+
</nowiki>}}
  
 
For example, the kernel line should look something like this after modification:
 
For example, the kernel line should look something like this after modification:
  
<pre>
+
{{ic|<nowiki>
 
kernel /vmlinuz26 root=/dev/md0 ro md=0,/dev/sda3,/dev/sdb3 vga=773 console=tty0 console=ttyS0,9600
 
kernel /vmlinuz26 root=/dev/md0 ro md=0,/dev/sda3,/dev/sdb3 vga=773 console=tty0 console=ttyS0,9600
</pre>
+
</nowiki>}}
  
Note: when the 'terminal --timeout=5 serial console' line is added to your menu.lst grub configuration, your boot sequence will now show a series of "Press any key to continue"  messages.  If no key is pressed, the boot menu will appear on which ever (serial or console) appear first in the 'terminal' configuration line.  The lines will look like this upon boot:
+
{{note|When the {{ic|<nowiki>terminal --timeout=5 serial console</nowiki>}} line is added to your menu.lst grub configuration, your boot sequence will now show a series of "Press any key to continue"  messages.  If no key is pressed, the boot menu will appear on whichever (serial or console) appears first in the 'terminal' configuration line.  The lines will look like this upon boot:}}
<pre>
+
 
 +
{{ic|
 +
Press any key to continue.<br>
 +
Press any key to continue.<br>
 +
Press any key to continue.<br>
 +
Press any key to continue.<br>
 +
Press any key to continue.<br>
 +
Press any key to continue.<br>
 
Press any key to continue.
 
Press any key to continue.
Press any key to continue.
+
}}
Press any key to continue.
+
Press any key to continue.
+
Press any key to continue.
+
Press any key to continue.
+
Press any key to continue.
+
</pre>
+
  
 
2. Edit the inittab file:  
 
2. Edit the inittab file:  
  
<pre>
+
vi /etc/inittab
# vi /etc/inittab
+
</pre>
+
  
Add a new agetty line below the existing ones :
+
Add a new agetty line below the existing ones:
  
<pre>
+
{{ic|
 
c0:2345:respawn:/sbin/agetty 9600 ttyS0 linux
 
c0:2345:respawn:/sbin/agetty 9600 ttyS0 linux
</pre>
+
}}
  
 
3. Edit the securetty file:
 
3. Edit the securetty file:
<pre>
 
# vi /etc/securetty
 
</pre>
 
  
Below the existing tty's add an entry for the the serial console:
+
vi /etc/securetty
<pre>
+
 
 +
Below the existing ttys, add an entry for the the serial console:
 +
 
 +
{{ic|
 
ttyS0
 
ttyS0
</pre>
+
}}
  
 
4. Reboot the machine
 
4. Reboot the machine
  
Note that in all of the steps above ttyS1 can also be used, in case that your machine has more than one serial port.
+
{{note|In all of the steps above, ttyS1 can also be used in case your machine has more than one serial port.}}
  
 
=Making Connections=
 
=Making Connections=
Line 86: Line 83:
 
====Minicom====
 
====Minicom====
  
1. Install Minicom:
+
1. Install {{Pkg|Minicom}}:
  
<pre>
+
pacman -S minicom
# pacman -S minicom
+
</pre>
+
  
 
2. Start Minicom in setup mode:
 
2. Start Minicom in setup mode:
  
<pre>
+
minicom -s
# minicom -s
+
</pre>
+
  
3. Using the textual navigation menu change the serial port settings to the following:
+
3. Using the textual navigation menu, change the serial port settings to the following:
  
<pre>
+
{{ic|
Serial Device: /dev/ttyS0
+
Serial Device: /dev/ttyS0<br>
 
Bps/Par/Bits: 9600 8N1
 
Bps/Par/Bits: 9600 8N1
</pre>
+
}}
  
Press Enter to exit the menus (pressing Esc will not save changes)
+
Press Enter to exit the menus (pressing Esc will not save changes).
  
 
4. Remove the modem Init and Reset strings:
 
4. Remove the modem Init and Reset strings:
  
Under the 'Modem and Dialing' menu delete the Init and Reset strings.
+
Under the 'Modem and Dialing' menu, delete the Init and Reset strings.
  
 
5. Save the setup:
 
5. Save the setup:
  
From the main menu, choose 'save setup as dfl'
+
From the main menu, choose 'save setup as dfl'.
  
 
6. Exit Minicom:
 
6. Exit Minicom:
  
From the main menu, choose 'Exit from Minicom'
+
From the main menu, choose 'Exit from Minicom'.
  
 
7. Connect to the target machine:
 
7. Connect to the target machine:
Line 123: Line 116:
 
While the serial cable is connected to the target machine, start the Minicom program:
 
While the serial cable is connected to the target machine, start the Minicom program:
  
<pre>
+
minicom
# minicom
+
</pre>
+
  
 
8. Exiting Minicom
 
8. Exiting Minicom
  
To finish the session press 'ctrl-A' and then 'X'.
+
To finish the session, press 'ctrl-A' and then 'X'.
  
 
====Screen====
 
====Screen====
Line 135: Line 126:
 
Screen is able to connect to a serial port. It will connect to a standard 9600 speed port without options.
 
Screen is able to connect to a serial port. It will connect to a standard 9600 speed port without options.
  
<pre>
+
screen /dev/ttyS0
# screen /dev/ttyS0
+
</pre>
+
  
If needed see the section "WINDOW TYPES" in the screen man page for details on setting the baud rate.
+
If needed, see the section "WINDOW TYPES" in the screen man page for details on setting the baud rate.
  
 
====Windows Options====
 
====Windows Options====
  
On Windows machines, connect to the serial port using programs like Putty or Hyper Terminal.
+
On Windows machines, connect to the serial port using programs like PuTTY or Hyper Terminal.
  
 
=Installing Arch Linux using the serial console=
 
=Installing Arch Linux using the serial console=
Line 153: Line 142:
 
After a while, output from the console will start showing on screen and setup can be started normally.
 
After a while, output from the console will start showing on screen and setup can be started normally.
  
Note that after setup is complete, the console settings will not be saved on the target machine, in order to avoid having to connect a keyboard and monitor, configure console access on the target machine before rebooting.
+
{{note|After setup is complete, the console settings will not be saved on the target machine; in order to avoid having to connect a keyboard and monitor, configure console access on the target machine before rebooting.}}
  
Note that while a port speed of 9600 is used in all of the examples in this document, working with higher values is recommended (List of available speeds is displayed in Minicom by pressing 'Ctrl-A' and then 'P')
+
{{note|While a port speed of 9600 is used in all of the examples in this document, working with higher values is recommended (List of available speeds is displayed in Minicom by pressing 'Ctrl-A' and then 'P')}}
  
 
=Troubleshooting=
 
=Troubleshooting=
 
====Ctrl-C and Minicom====
 
====Ctrl-C and Minicom====
 
If you are having trouble sending a Control-C command through minicom you need to switch off hardware flow control in the device settings (minicom -s), which then enables the break.
 
If you are having trouble sending a Control-C command through minicom you need to switch off hardware flow control in the device settings (minicom -s), which then enables the break.

Revision as of 03:49, 20 February 2012

Introduction

Configure your Arch Linux machine so you can connect to it via the serial console port (com port). This will enable you to administer the machine even if it has no keyboard, mouse, monitor, or network attached to it (a headless server).

As of Arch Linux 2007.x, installation of Arch Linux is possible via the serial console as well.

A basic environment for this scenario is two machines connected using a serial cable (9-pin connector cable). The administering machine can be any Linux or Windows machine with a terminal emulator program (PuTTY or Minicom, for example).

The configuration instructions below will enable GRUB menu selection, boot messages, and terminal forwarding to the serial console.

Configuration

Configure console access on the target machine

1. Edit the GRUB config file:

vi /boot/grub/menu.lst

Add these lines to the general area of the configuration:

serial --unit=0 --speed=9600
terminal --timeout=5 serial console

Add the console parameters at the end of your current kernel line:

console=tty0 console=ttyS0,9600

For example, the kernel line should look something like this after modification:

kernel /vmlinuz26 root=/dev/md0 ro md=0,/dev/sda3,/dev/sdb3 vga=773 console=tty0 console=ttyS0,9600

Note: When the terminal --timeout=5 serial console line is added to your menu.lst grub configuration, your boot sequence will now show a series of "Press any key to continue" messages. If no key is pressed, the boot menu will appear on whichever (serial or console) appears first in the 'terminal' configuration line. The lines will look like this upon boot:

Press any key to continue.
Press any key to continue.
Press any key to continue.
Press any key to continue.
Press any key to continue.
Press any key to continue.
Press any key to continue.

2. Edit the inittab file:

vi /etc/inittab

Add a new agetty line below the existing ones:

c0:2345:respawn:/sbin/agetty 9600 ttyS0 linux

3. Edit the securetty file:

vi /etc/securetty

Below the existing ttys, add an entry for the the serial console:

ttyS0

4. Reboot the machine

Note: In all of the steps above, ttyS1 can also be used in case your machine has more than one serial port.

Making Connections

Connect using a terminal emulator program

Perform these steps on the machine used to connect the remote console.

Minicom

1. Install Minicom:

pacman -S minicom

2. Start Minicom in setup mode:

minicom -s

3. Using the textual navigation menu, change the serial port settings to the following:

Serial Device: /dev/ttyS0
Bps/Par/Bits: 9600 8N1

Press Enter to exit the menus (pressing Esc will not save changes).

4. Remove the modem Init and Reset strings:

Under the 'Modem and Dialing' menu, delete the Init and Reset strings.

5. Save the setup:

From the main menu, choose 'save setup as dfl'.

6. Exit Minicom:

From the main menu, choose 'Exit from Minicom'.

7. Connect to the target machine:

While the serial cable is connected to the target machine, start the Minicom program:

minicom

8. Exiting Minicom

To finish the session, press 'ctrl-A' and then 'X'.

Screen

Screen is able to connect to a serial port. It will connect to a standard 9600 speed port without options.

screen /dev/ttyS0

If needed, see the section "WINDOW TYPES" in the screen man page for details on setting the baud rate.

Windows Options

On Windows machines, connect to the serial port using programs like PuTTY or Hyper Terminal.

Installing Arch Linux using the serial console

1. Connect to the target machine using the method described above.

2. Boot the target machine using the Arch Linux installation CD.

After a while, output from the console will start showing on screen and setup can be started normally.

Note: After setup is complete, the console settings will not be saved on the target machine; in order to avoid having to connect a keyboard and monitor, configure console access on the target machine before rebooting.
Note: While a port speed of 9600 is used in all of the examples in this document, working with higher values is recommended (List of available speeds is displayed in Minicom by pressing 'Ctrl-A' and then 'P')

Troubleshooting

Ctrl-C and Minicom

If you are having trouble sending a Control-C command through minicom you need to switch off hardware flow control in the device settings (minicom -s), which then enables the break.