Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
25
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

...............................................................................................

Additional TCP options:.

Starting background filesystem checks

Tue Jul 10 19:40:21 EDT 2001

...............................................................................................

This is almost exactly like being at the console, except you get no logon prompt.

Serial Login

By default, serial ports are not treated as logon devices. Many people use their serial ports for serial mice or modems, not for console connections, and if you put mouse movements into a logon prompt, the system will be confused at best. You can use a serial port as a mouse port, a modem port, or a console port, but not all at the same time. People who want to get a logon prompt over a serial line are generally assumed to know how to activate the terminal on that port.

To activate the terminal, first check the /etc/ttys file for a list of all the terminals and pseudo−terminals on the system. The serial port is just another terminal. In terminal−speak, sio0/com1 is known as ttyd0, for "tty dialup 0".[2] Find the line for ttyd0:

...............................................................................................

ttyd0 "/usr/libexec/getty std.9600" dialup off secure

...............................................................................................

The fourth field in this line says that this terminal is off. Change that "off" to "on", and then it's time to restart the daemon init, or process ID 1, that pro− vides terminal services. You don't need to check ps output to get the process ID of init; init always has the process ID 1. If init is not running, the system is not running, and you can restart it gracefully with the −1 signal.

...............................................................................................

# kill −1 1

...............................................................................................

Once you do this, you'll abruptly see activity on your serial console.

...............................................................................................

Tue Jul 10 19:50:02 EDT 2001

FreeBSD/i386 (magpire.blackhelicopters.org) (ttyd0)

login:

...............................................................................................

Emergency Logon Setup

In some very bad situations, a FreeBSD system might stop talking to the network. Perhaps the network card has gone bad, or the system panics when some program starts. I was once in a situation where a server on the other side of the country panicked upon boot because the database program crashed the whole system as soon as it started. The system would reboot, check its disks, start up its programs, and crash. I needed to add one command−line option to the database program's startup script for the crashes to stop.

469

The problem, though, was that the system wouldn't be up long enough for me to SSH in, become root, and shut down the database. While I had a serial console, it wasn't configured to allow logins. I could sit there on the serialconsole and watch the panic message appear over and over again, all the while thinking, "You know, if I could just log in over this serial port, I could fix that startup script." Here's how to do exactly that. While you might never need this, if you do, you'll be grateful you know it.

Because FreeBSD does not restrict console access until the system reaches multi−user mode, you can interrupt the boot process, boot to single−user mode, and make your changes. To do so, open your serial−console connection, and then get someone on the other end to power−cycle the machine. (This isn't good for your computer, but neither is repeated crashing!) Now boot into single−user mode, and at a command prompt, do the following:

...............................................................................................

# fsck −p

...............................................................................................

This will clean up any damage done by the power cycle. Now run this:

...............................................................................................

# mount −a

...............................................................................................

You can now access your local filesystems. Now, edit the /etc/ttys file to enable the serial port logon as described in the previous section. Here you can also edit the startup script that's causing the system to crash.

Exit the shell to complete the boot, and you'll be able to log in via the serial console.

Disconnecting the Serial Console

The tip(1) program uses the tilde (~) as a control character. To disconnect the serial console, enter the disconnect sequence "tilde−period" at any time:

...............................................................................................

~.

...............................................................................................

You'll be gracefully disconnected, but not logged out (serial is a very loose protocol). If you go back in and type tip com2 again, you'll be back at your login session. If server1 has a cable plugged into the console port of server2, it might look like this:

...............................................................................................

server1#tip com1 connected

server2#

...............................................................................................

This might not worry you, but a break−in on server1 would immediately compromise server2. Make it an unbreakable habit to log out when you're connected via serial!

470