Redirecting Linux console messages to another machine

From WBITT's Cooker!

Jump to: navigation, search

Here I am going to present how to redirect console messages from virtual machine to physical (base) machine. We used, in our lab, one physical machine running Linux OS and created one virtual machine in it.

Requirement:

  • One physical machine running Linux OS
  • Created one virtual machine (Linux OS)

Here are the steps we followed in our lab to accomplish this assignment.

Before we begin, it is important to know that your Serial Ports (COM1 and COM2) are named as /dev/ttyS0 and /dev/ttyS1 respectively and so on.

Check if Linux detects your serial port or not. One way you could do is to give the following command:

#dmesg |grep ttyS

You should see something like this:

Example:

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

The above output shows that your COM1 and COM2 ports are available and Linux recognizes them.

Another way to test is to give the following command:

# ls > /dev/ttyS0

If the command does not return any error message then your Serial Ports are recognized by your Linux system. In case, Linux does not detect your Serial Port, then try giving the following command:

#setserial /dev/ttyS0 autoconfig auto_irq

Well, above we just discussed only basics of how to find serial ports installed in our machine.

Here, the actual work starts. On guest machine, we need to make few changes in the grub file which was created in our lab.

Add the following line to grub.conf file of guest machine. Open the grub.conf file using VI editor and append the following lines to it.

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

And also in the grub.conf file, append the following parameters right after the kernel value as shown below.

#vi /etc/grub.conf
kernel /vmlinuz-2.4.9-21 ro root=LABEL=/ console=tty0 console=ttyS0,115200
:wq
#

Create a copy of the inittab file and add the following line to it.

#cp /etc/inittab /etc/inittab.orig
#vi /etc/inittab
co:23:respawn:/sbin/agetty ttyS0 115200 linux
:wq
#init q

Well, now we need to reboot our guest machine and check whether it is accessible using the following command.

#Virsh console Node1
Personal tools