您的位置:首页 > 其它

How-To set up a serial console on Debian

2017-01-11 15:13 411 查看
转自:https://www.debuntu.org/how-to-set-up-a-serial-console-on-debian/

This tutorial will go over the steps to go through in order to set up a
serial console
on Debian Linux.

Debian uses sysvinit to handle the booting process, amongst the different task, and as such, there is a few differences between most of the tutorial that you might find on the internet regarding how to set up a serial console.

A Serial Console becomes handy when running a headless server (i.e no keyboard and screen) or if you cannot connect a a server because of a network issue.

In this tutorial, we will set up a serial console on the
server, the machine we want an access to. Setting up a serial console client will be covered in another article.

1. Checking the serial devices

In order to find which devices are available on a box, you can run:

//本地console口

$ dmesg | grep tty

serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A

00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

00:0a: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
From this output, we can guess that there is 2 serial interface2 (/dev/ttyS0 and
/dev/ttyS1). This tutorial considers that you are using device 1 (ttyS0), if you use the second device, you will need to change ttyS0 by ttyS1.

2. Setting up the serial console on the server

On the server, we are going to set up:

A serial console on ttyS0Have kernel booting messages output to the serial console
Make Grub outputs to the serial console

2.1. The serial console

To set up a serial console, We need to edit the file called /etc/inittab in order to spawn a
getty on the serial device. getty will take care of prompting the user for a username and password.

//设置开机配置环境,强制console口运行环境

Go and edit /etc/inittab and add:

s0:2345:respawn:/sbin/getty -L 115200 ttyS0 vt102

just below:

1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

Now, run:

# init q
In order to have sysvinit re-read its configuration and spawn a getty on
/dev/ttyS0 .

To authorize root to log in through the serial console, you need to edit /etc/securetty and make sure you have:

ttyS0

2.2. Having grub outputting to ttyS0

grub can be configured to output on the serial console.Edit grub and add:

serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console

In the section before the different kernels. This will take care of having grub being displayed one the serial console so you can actually modify grub through the serial console or boot using another kernel.

If using ttyS1, then change it to --unit=1
Also, in order to get the booting messages outputted to the serial console, you can append to your
kernel line the following:

console=ttyS0,115200n8 console=tty0

So, finally, the kernel line will look like:

kernel          /boot/vmlinuz-2.6.18-6-686 root=/dev/sda1 ro console=ttyS0,115200n8 console=tty0

That's it, upon next reboot, you will be able to connect directly to your box using a serial console!.

Related posts:

How-To set up a serial console on Ubuntu
How-To set up a serial console client
How To: Installing Debian Etch From a running Debian based system — page 2
How-To: Set up a LAN gateway with DHCP, Dynamic DNS and iptables on Debian Etch — page 2 — DNS server

Tags: system

This entry was posted on Saturday, May 3rd, 2008 at 2:26 pm and is filed under Administration, HowTo, System. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: