s i s t e m a o p e r a c i o n a l m a g n u x l i n u x | ~/ · documentação · suporte · sobre |
3. Configuring Linux for Serial ConsolesThere is two parts to getting a serial console set up under Linux. First, you must tell Linux to redirect its console output to the serial port. Second, you must set up mgetty to start a login process on the serial port once the kernel has completed booting. Some distributions use mingetty for the video console, but mingetty has no serial port support. You will instead want to use mgetty. A third (optional) configuration is to set the hardware BIOS to redirect its POST and BIOS information to the serial port. Check your motherboard documentation for more information about this. 3.1. Configuring LILO and the Linux KernelIf you're using LILO as your bootloader, you can quickly test using serial console from Linux by entering:
Assuming the LILO tag for your Linux kernel is called "Linux". Change this for the name of your kernel. The generic format for the console option is console=device,options. You can give multiple console statements, and kernel messages will go to all listed devices, but the last one listed will be used as /dev/console.
You should see the Linux kernel start through the decompression process then you will see no more on-screen information until the kernel has completed and mgetty starts up a login prompt on the screen. If you are monitoring the serial port, you'll see the Linux bootup information coming over the serial port. However, you probably will not see a login prompt on the serial port (yet). We'll cover that in Section 3.2. Once you are sure this is working, you can now edit LILO to pass this information to the kernel each time it boots. You can also configure LILO to send its prompt to the serial port. Fire up your favorite editor of choice and load up the /etc/lilo.conf file. You will want to add two lines, one to the general configuration and one to the specific kernels you want to use.
The append statement contains the statement we listed above, and tells Linux to send its output to the serial port. The serial command goes to LILO, and tells it to open port 0 (ttyS0, or COM1). The options for serial are the same as to the console statement.
Re-run /sbin/lilo and reboot. You should now see everything except the login prompt on the serial port. Information should still be going to the monitor, just in case you have problems with the serial port. 3.2. Configuring getty for use with serial portsSome distributions may ship with mingetty that does not support serial ports. The first thing you have to do is make sure the version of getty you are using supports serial ports. Both agetty and mgetty do this. So run off now using your favorite packaging system to make sure this is the case. Don't worry, this document will still be here when you get back. Back so soon? Great! Let's get that serial port configured. You will want to make sure that all your serial port settings are consistent. No sense in making getty run at 9600bps, while LILO and the kernel are talking 19200. To get login prompts to appear on the serial port, edit the /etc/inittab file and add a line similar to the following:
The format for entries in inittab are covered in most basic Linux and UNIX books, but to repeat, each field is separated by a colon (:) and represent:
The entries in /etc/inittab will be loaded into init when root sends a HUP signal.
Now that getty is set up, you will be able to go from powerup to login prompt all over the serial port |