Category: Easy debugging technique

Using serial ports to capture logs in virtual machines

Introduction

Most of the virtualization products provide ability to attach virtual serial ports these days.
There are two ways you can use serial ports in virtual environment.
  • Using physical serial ports on host computer
  • Using file on host computer
I would throw some light on connecting virtual serial ports to files on host computer.
Usecase
Some beneficial usecases –
  1. For Administrators – In case of servers running multiple applications on guests. On application failures, or virtual machine failures, instead of using physical serial ports to redirect logs on some other system, we can use virtula serial ports for each VM, which would redirect logs on files residing on host(server).This way admins can easily track the progress/working/behavior of application by tracking logs.
  2. For Developers – For kernel developers, most of the times it is difficult to get the logs when any absurd issue strikes their way and makes their life uneasy to get to the issue. There are several methods to captures logs. But what about the case when kernel crashes during boot itself ? Would you be able to capture the logs locally to find whats fishy inside the kernel component ? Well I think Yes !!! Moreover the following techniques would also helpful to eradicate problems when logs get rolled over in the system as they are too much in number.

Using file on host computer (VMware Workstation)

Following are the steps to enable redirection of logs on host computer

  • Changing grub settings.

Go to /boot/grub/grub.conf and edit the config file by adding
“console=ttyS0 console=tty0 ignore_loglevel”  parameters.

  • Virtual machine settings

a) Add a new serial port for the VM and use Output File option.
b) Mention the location of log file(on host) in File Path textbox.

Grub Settings
VMware workstation settings

Using file on host computer (Oracle VirtualBox Manager)

  • Changing grub settings.

Go to /boot/grub/grub.conf and edit the config file by adding
“console=ttyS0 console=tty0 ignore_loglevel”  parameters.

  • Virtual machine settings

a) Add a new serial port for the VM and name it as COM1.
b) Select port mode as Raw file.
c) Mention the location of log file(on host) in File Path textbox.

Grub Settings
VM settings
Advertisements