[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howtos:general_admin:serial_console [2012/12/20 02:16 (UTC)] – [Sources] added author tag mfillpothowtos:general_admin:serial_console [2014/11/14 09:18 (UTC)] (current) – add GRUB2 section fdonkers
Line 1: Line 1:
 +<!-- Reviewed 2013-01-06 mfillpot -->
 <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). -->
 ====== Serial Console ====== ====== Serial Console ======
 +Slackware can be installed on various embedded devices. A lot of those don't
 +have a traditional console, like a monitor and keyboard. Instead, the console
 +is often routed to the serial port. In order to take advantage of this, some
 +post-install configuration is necessary.
  
-Slackware can be installed on various embedded devices. A lot of those don't have a traditional console, like a monitor and keyboard. Instead, the console is often routed to the serial port. In order to take advantage of this, some post-install configuration is necessary.  +This howto can also be used to setup a serial console on an existing headless 
- +server as a backup for administering the machine.
-This howto can also be used to setup a serial console on an existing headless server as a backup for administering the machine. +
  
 ====== Preparation ====== ====== Preparation ======
 +You need to know the serial device and the speed. The device will mostly be
 +ttyS0, the first serial device. If you are using a serial to USB adapter, it
 +will likely be ttyUSB0. Consult the documentation of your board if you are
 +not sure.
  
-You need to know the serial device and the speed. The device will mostly be ttyS0, the first serial deviceIf you are using a serial to USB adapter, it will likely be ttyUSB0. Consult the documentation of your board if you are not sure+Some devices have an option in the BIOS to change the speed and other serial 
 +settingsMake sure you know the speed that is currently set.
  
-Some devices have an option in the BIOS to change the speed and other serial settings. Make sure you know the speed that is currently set.  +In the below examples we will assume ttyS0 with speed 38400.
- +
-In the below examples we will assume ttyS0 with speed 38400. +
  
 ====== Host configuration ====== ====== Host configuration ======
- 
 ===== Activate serial port ===== ===== Activate serial port =====
 +Edit ''/etc/inittab'' and uncomment the correct serial console line. Change
 +the speed setting when required.
  
-Edit ''/etc/inittab'' and uncomment the correct serial console line. Change the speed setting when required.  +<file - /etc/inittab>
-  +
-<code>+
 # Local serial lines: # Local serial lines:
 s1:12345:respawn:/sbin/agetty -L ttyS0 38400 vt100 s1:12345:respawn:/sbin/agetty -L ttyS0 38400 vt100
 #s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100 #s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100
-</code>+</file>
  
 ===== Allow root login ===== ===== Allow root login =====
- +Edit ''/etc/securetty'' and uncomment your serial device to allow root to 
-Edit ''/etc/securetty'' and uncomment your serial device to allow root to login via the serial console. You can omit this step if you will access the machine with a normal user id.  +login via the serial console. You can omit this step if you will access the 
- +machine with a normal user id. 
-<code>+<file - /etc/securetty>
 # These are some remote ttys, and uncommenting them might be less than fully secure: # These are some remote ttys, and uncommenting them might be less than fully secure:
 ttyS0 ttyS0
 #ttyS1  #ttyS1 
-</code>+</file>
  
 ===== Setup LILO boot loader ===== ===== Setup LILO boot loader =====
- +Edit ''/etc/lilo.conf''. Add a line to the general section: 
-Edit ''/etc/lilo.conf''. Add a line to the general section:  +<file - /etc/lilo.conf>
-<code>+
 serial=0,38400n8 serial=0,38400n8
-</code>+</file>
  
-The 0 refers to the first serial device, ttyS0. +The 0 refers to the first serial device, ttyS0.
  
-Add the following parameter to the kernel line:  +Add the following parameter to the kernel line: 
-<code>+<file - /etc/lilo.conf>
 append="console=ttyS0,38400n8" append="console=ttyS0,38400n8"
-</code>+</file>
  
-If the ''append'' line already exists, add the parameter as follows:  +If the //append// line already exists, add the parameter as follows: 
-<code>+<file - /etc/lilo.conf>
 append="mem=1024M console=ttyS0,38400n8" append="mem=1024M console=ttyS0,38400n8"
-</code>+</file>
  
 Now run ''/sbin/lilo'' to write the new bootloader configuration. Now run ''/sbin/lilo'' to write the new bootloader configuration.
  
-To have the console on normal tty as well as serial port, adjust the kernel line as follows: +To have the console on normal tty as well as serial port, adjust the 
-  +kernel line as follows: 
-<code>+<file - /etc/lilo.conf>
 append="console=tty0 console=ttyS0,38400" append="console=tty0 console=ttyS0,38400"
-</code>+</file>
  
-===== Setup GRUB boot loader =====+===== Setup GRUB-legacy boot loader ===== 
 +Edit ''/boot/grub/menu.lst'' and change it as follows:
  
-Edit ''/boot/grub/menu.lst'' and change it as follows: 
-  
 Add lines to the general section as follows: Add lines to the general section as follows:
- +<file - /boot/grub/menu.lst>
-<code>+
 serial --speed=38400 serial --speed=38400
 terminal serial terminal serial
-</code>+</file>
  
 Add the following parameter to the kernel line: Add the following parameter to the kernel line:
-<code>+<file - /boot/grub/menu.lst>
 console=ttyS0,38400n8 console=ttyS0,38400n8
-</code>+</file>
  
-The complete kernel line might look like this: +The complete kernel line might look like this (substitute your root 
- +partition and vmlinuz file): 
-<code>+<file - /boot/grub/menu.lst>
 kernel /boot/vmlinuz root=/dev/sda2 ro vga=normal console=ttyS0,38400n8 kernel /boot/vmlinuz root=/dev/sda2 ro vga=normal console=ttyS0,38400n8
-</code+</file>
  
-To have the console on normal tty as well as serial port, adjust the terminal and kernel lines as follows: +To have the console on normal tty as well as serial port, adjust the 
-  +terminal and kernel lines as follows: 
-<code>+<file - /boot/grub/menu.lst>
 terminal --timeout=5 serial console terminal --timeout=5 serial console
-</code><code>+</file> 
 +<file - /boot/grub/menu.lst>
 kernel xxx console=tty0 console=ttyS0,38400n8 kernel xxx console=tty0 console=ttyS0,38400n8
 +</file>
 +
 +When the terminal timeout expires, the first option (in this case serial)
 +will be chosen as the console. The normal bootloader timeout will start
 +when the terminal timeout ends.
 +
 +===== Setup GRUB2 boot loader =====
 +Edit file ''/etc/default/grub'' and change the following line to define the console:
 +<file . grub>
 +GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0,38400n8"
 +</file>
 +
 +Add the following lines to define the console settings:
 +<file . grub>
 +GRUB_TERMINAL=serial
 +GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --word=8 --parity=no --stop=1"
 +</file>
 +
 +Now rebuild the GRUB2 configuration: 
 +<code>
 +# grub-mkconfig -o /boot/grub/grub.cfg
 </code> </code>
- 
-When the terminal timeout expires, the first option (in this case serial) will be chosen as the console. The normal bootloader timeout will start when the terminal timeout ends. 
  
 ====== Connect from a remote computer ====== ====== Connect from a remote computer ======
 +To use the serial console, you need to attach a second computer to the
 +serial port of the host. Use a null modem cable. Most modern computers no
 +longer have a serial port so you might need a serial to USB connector as
 +well.
  
-To use the serial console, you need to attach a second computer to the serial port of the host. Use a null modem cable. Most modern computers no longer have a serial port so you might need a serial to USB connector as well.  +Once you have physically connected the machines, you need a communications 
- +package to interact with the console. Two popular options are **screen** 
-Once you have physically connected the machines, you need a communications package to interact with the console. Two popular options are //screen// and //minicom//+and **minicom**.
  
 ===== Connect using screen ===== ===== Connect using screen =====
 +This is the easiest option because it doesn't need any configuration.
 +Start **screen** and specify the serial device and the desired speed on the
 +command line.
 +<code>
 +user@darkstar$ screen /dev/ttyUSB0 38400
 +</code>
  
-This is the easiest option because it doesn't need any configuration. Start ''screen'' and specify the serial device and the desired speed on the command line. +===== Connect using minicom ===== 
 +Before using minicom, you need to configure it. Start with the ''-s'' switch 
 +as follows:
 <code> <code>
-screen /dev/ttyUSB0 38400+user@darkstar$ minicom -s
 </code> </code>
-  
-===== Connect using minicom ===== 
- 
-Before using minicom, you need to configure it. Start with the ''-s'' switch as follows: 
- 
-<code>minicom -s</code> 
  
 You will see the main menu. You will see the main menu.
- 
 <code> <code>
  +-----[configuration]------+  +-----[configuration]------+
Line 130: Line 158:
 </code> </code>
  
-Select //Serial port setup//. You will see the serial port settings.  +Select //Serial port setup//. You will see the serial port settings.
 <code> <code>
     +-----------------------------------------------------------------------+     +-----------------------------------------------------------------------+
Line 146: Line 173:
 </code> </code>
  
-Use the <key>'A'</key> to <key>G</key> keys to change various settings. Make sure the //device// and //Bps/Par/Bits// settings are correct. Hit <key>Enter</key> to return to the main screen and select the //Modem and dialing// option. On the detail screen, make sure the //Init string// and //Reset string// options are empty. Hit <key>Enter</key> again to return to the main screen. Now you can save your options. Use //Save setup as dfl// to save this as your new default. Use //Save setup as..// to save as a certain profile. +Use the <key>'A'</key> to <key>G</key> keys to change various settings. 
 +Make sure the //device// and //Bps/Par/Bits// settings are correct. Hit 
 +<key>Enter</key> to return to the main screen and select the 
 +//Modem and dialing// option. On the detail screen, make sure the 
 +//Init string// and //Reset string// options are empty. Hit <key>Enter</key> 
 +again to return to the main screen. Now you can save your options. Use 
 +//Save setup as dfl// to save this as your new default. Use 
 +//Save setup as..// to save as a certain profile.
  
-Call minicom again and the new options will take effect.  +Call minicom again and the new options will take effect. 
- +<code> 
-<code>minicom</code>+user@darkstar$ minicom 
 +</code>
  
 Or you can start with a certain configuration Or you can start with a certain configuration
 +<code>
 +user@darkstar$ minicom myprofile
 +</code>
  
-<code>minicom myprofile</code> +Use <key>C-a</key><key>Z</key> for help. Use <key>C-a</key>,<key>X</key> 
- +to quit.
-Use <key>CTRL-A</key><key>Z</key> for help. Use <key>CTRL-A</key><key>X</key> to quit.+
  
 ====== Troubleshooting ====== ====== Troubleshooting ======
- 
 ===== Garbled characters in terminal ===== ===== Garbled characters in terminal =====
- +When you see progress in the terminal but the characters are garbled and 
-When you see progress in the terminal but the characters are garbled and unreadable, make sure you have the same speed set in the following sections: BIOS, bootloader and inittab. Also make sure your client connects with the same speed.+unreadable, make sure you have the same speed set in the following 
 +sections: BIOS, bootloader and inittab. Also make sure your client connects 
 +with the same speed.
  
 ===== Unable to sign on as root ===== ===== Unable to sign on as root =====
- +Check the ''securetty'' settings. See section above.
-Check the ''securetty'' settings. See section above. +
  
 ===== Unable to use screen or minicom as a regular user ===== ===== Unable to use screen or minicom as a regular user =====
- 
 When you get authorization problems using the serial device, make sure your user is in the ''dialout'' group. When you get authorization problems using the serial device, make sure your user is in the ''dialout'' group.
  
 ====== Further reading ====== ====== Further reading ======
- +  * Check the official [[http://www.tldp.org/HOWTO/Remote-Serial-Console-HOWTO | Remote Serial Console HOWTO]] for much more details. 
-  * Check the official [[http://www.tldp.org/HOWTO/Remote-Serial-Console-HOWTO | Remote Serial Console HOWTO]] for much more details.  +  * screen [[http://www.gnu.org/software/screen/manual|manual]]
-  * screen [[http://www.gnu.org/software/screen/manual|manual]] +
   * ''man 1 minicom''   * ''man 1 minicom''
  
Line 190: Line 225:
 <!-- You must remove the tag-word "template" below before saving your new page --> <!-- You must remove the tag-word "template" below before saving your new page -->
 {{tag>howtos console serial embedded author_fdonkers}} {{tag>howtos console serial embedded author_fdonkers}}
 +
 howtos:general_admin:serial_console ()