HOWTO get virtualbox to redirect to a console COM1 / ttya for debbuging

This is a short HOWTO on getting virtualbox (vbox) to redirect output to COM1 aka ttya so you can connect via a “serial” connection outside of the virtual machine.  A few things you can use this for is logging the console output on boot or login from your normal work terminal of choice.

To start..

1) If you’re on an opensolaris host.. You’ll need socat or nc.  (Thanks go to Triskelios for pointing out nc will work as well)

If you’re on ips

pkg install SUNWnetcat

or build socat-1.7 (2.x doesn’t build and I haven’t as of today had a chance to file a bug or send a patch.. someone should do this *cough* )

http://www.dest-unreach.org/socat/

(Not sure if it’ll build with sun cc.. I was lazy and used gcc this time..)

2) Next configure your serial connection for the virtual machine..

enable serial ports

COM1

use host-pipe

create pipe

# then put the path ( I used /tmp/vboxlog )

3) When the virtual machine starts you’ll see /tmp/vboxlog now exists

socat unix-client:/tmp/vboxlog stdout

or

nc -U /tmp/vboxlog

or

socat unix-client:/tmp/vboxlog stdout | tee boot.log

4) Modify your kernel line for grub to look like..

kernel /platform/i86pc/multiboot -B console=ttya,ttya-mode=”115200,8,n,1,-”

—-

From here you should be in business to catch the console output for the virtual machine when it boots.  Once you stop seeing output you can just connect without tee and login like normal..