Skip to end of metadata
Go to start of metadata

If you are using a newer VirtualBox as a hypervisor (since VirtualBox 5.x), then it should support publishing a serial port directly as a TCP socket onto which you can just telnet.

The instructions below are still valid for "Host pipe" socket backends, if you do not want the serial port accessible over the network or if you are constrained by an older version of the hypervisor.

Here are some notes on how to use a serial console with illumos running as a guest in VirtualBox. As suggested by the VirtualBox support site, I use the socat program in the low-level examples below.

Build and install the "socat" program

Make sure you have readline installed

Normally, it should already be there. You can check with:

Download socat-

I found it Here

Configure and build socat

I did it like this:

Install socat

If you're paranoid, do it like this:

and then look at what that prints, and do that by hand as root.
If you're more trusting, you can just:

Make a script, i.e socat-pipe

Mine contains the following: (improvements welcome!)

The trap line restores your terminal's settings to defaults when the script exits or is killed. (See below for other variants.)

Use the "socat-pipe" script to connect to your VM

In VirtualBox, open the "settings" for your guest VM, and get to the "Serial Ports" page, "Port 1" tab.
Check the box "Enable Serial Port", and set the "Port Number" to COM1, the "Port Mode" to "Host Pipe", check "Create Pipe", and fill in the "Port/File Path" string with something like:

Start your guest VM, then run "socat-pipe" like this:

If you don't want to always use the serial console with your VM, you can press 'e' during the grub menu, then add -B console=ttya to the kernel line only for those occasions when you want to use that.
(You probably also want to add '-k' to get kmdb.)

Disconnecting from socat

It is possible to define one of the 127 ASCII control codes as the escape character that closes socat.
Simply add escape=0xXX to your socat options, for example, I use ctrl+q (0x11) to close my socat terminal, so I run:

Which means you can just replace the line in the script above with:

To have ctrl+q work as a way to close socat.

For a full table see 

Alternative script for socat-1.6.x, socat-1.7.0

I am using an expanded version of Gordon's script to loop executions of socat for my VMs. This way, if the VM reboots (closing the pipe), there is soon a new socat spawned to reattach to the console.
The script also includes a command-line option -s to kill an existing script looping socats, as a workaround to the lack of a tilde-escape. 
Exit-options for stty were picked for my desktop (twm in VNC): fall back to "sane" settings and redefine the backspace character; YMMV.

Note for users of vboxsvc (the SMF wrapper project): as of the vboxsvc release 0.17, the socat serial console logic derived from the script below was embedded into script as sercon and sercon-break methods which can auto-detect the specified VM's serial console (pipe file on the host) or use one provided explicitly.

Hope this helps,

//Jim Klimov


I'm using socat version 1.7.1, which allows me to wrap the raw serial connection presented by the pipe with a PTY:

I'm just learning socat, but this appears necessary to provide terminal emulation on the console.