Tech: Accessing a serial console on a VMware Linux virtual machine

A VMware user posted a nice how-to involving a tool called socat on VMTN Forums:

Create the serial ports within the VM

  1. With your virtual machine stopped and using the GUI vmware console click on the “add hardware” button
  2. Add a serial port with the following parameters:
    • Connect at Power On: checked
    • Use Named Pipe
    • Output file is ./serial1
    • This end is the server
    • The other end is an application
  3. You may want to add a second serial port now

Note: At this point you have told vmware to create the file ./serial1 in the directory containing the other files for this VM. This file won’t be created until you start the VM the next time.

Start the VM

Start the VM. As soon as the VM reaches the BIOS prompt it will have created the special file ./serial1 on the VMware host machine.

Connect to the Special File

VMware calls this a “Named Pipe”, but it’s actually a Unix Domain Socket. A named pipe can be opened as a file, but a UDS cannot. Instead, I use this hackish command to get to the UDS.

socat -d -d -d /var/lib/vmware/Virtual\ Machines/vmtestcli5/serial2tcp4-listen:9988

This links the Unix Domain Socket to port 9988 on the local machine.
Using telnet open port 9988 on the vmware host machine. You will be able to communicate into and out of the serial port.

Rather than “tcp4-listen:9988” you can use “stdio” to go directly to/from a shell on the vmware host server.
Any control characters do not get passed through appropriately.