====== 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.
This howto can also be used to setup a serial console on an existing headless
server as a backup for administering the machine.
====== 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.
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.
====== Host configuration ======
===== Activate serial port =====
Edit ''/etc/inittab'' and uncomment the correct serial console line. Change
the speed setting when required.
# Local serial lines:
s1:12345:respawn:/sbin/agetty -L ttyS0 38400 vt100
#s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100
===== Allow root login =====
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.
# These are some remote ttys, and uncommenting them might be less than fully secure:
ttyS0
#ttyS1
===== Setup LILO boot loader =====
Edit ''/etc/lilo.conf''. Add a line to the general section:
serial=0,38400n8
The 0 refers to the first serial device, ttyS0.
Add the following parameter to the kernel line:
append="console=ttyS0,38400n8"
If the //append// line already exists, add the parameter as follows:
append="mem=1024M console=ttyS0,38400n8"
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:
append="console=tty0 console=ttyS0,38400"
===== Setup GRUB-legacy boot loader =====
Edit ''/boot/grub/menu.lst'' and change it as follows:
Add lines to the general section as follows:
serial --speed=38400
terminal serial
Add the following parameter to the kernel line:
console=ttyS0,38400n8
The complete kernel line might look like this (substitute your root
partition and vmlinuz file):
kernel /boot/vmlinuz root=/dev/sda2 ro vga=normal console=ttyS0,38400n8
To have the console on normal tty as well as serial port, adjust the
terminal and kernel lines as follows:
terminal --timeout=5 serial console
kernel xxx console=tty0 console=ttyS0,38400n8
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:
GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0,38400n8"
Add the following lines to define the console settings:
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --word=8 --parity=no --stop=1"
Now rebuild the GRUB2 configuration:
# grub-mkconfig -o /boot/grub/grub.cfg
====== 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.
Once you have physically connected the machines, you need a communications
package to interact with the console. Two popular options are **screen**
and **minicom**.
===== 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.
user@darkstar$ screen /dev/ttyUSB0 38400
===== Connect using minicom =====
Before using minicom, you need to configure it. Start with the ''-s'' switch
as follows:
user@darkstar$ minicom -s
You will see the main menu.
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
| Exit from Minicom |
+--------------------------+
Select //Serial port setup//. You will see the serial port settings.
+-----------------------------------------------------------------------+
| A - Serial Device : /dev/ttyS1 |
| B - Lockfile Location : /var/lock |
| C - Callin Program : |
| D - Callout Program : |
| E - Bps/Par/Bits : 115200 8N1 |
| F - Hardware Flow Control : Yes |
| G - Software Flow Control : No |
| |
| Change which setting? |
+-----------------------------------------------------------------------+
Use the 'A' to G keys to change various settings.
Make sure the //device// and //Bps/Par/Bits// settings are correct. Hit
Enter 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 Enter
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.
user@darkstar$ minicom
Or you can start with a certain configuration
user@darkstar$ minicom myprofile
Use C-a, Z for help. Use C-a,X
to quit.
====== Troubleshooting ======
===== Garbled characters in terminal =====
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.
===== Unable to sign on as root =====
Check the ''securetty'' settings. See section above.
===== 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.
====== Further reading ======
* 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]]
* ''man 1 minicom''
====== Sources ======
* Originally written by [[wiki:user:fdonkers | Frank Donkers]].\\
{{tag>howtos console serial embedded author_fdonkers}}