Virtualbox Serial Port Connection
- Virtualbox Serial Port Settings
- Virtualbox Com Port
- Virtualbox Serial Port Connection Software
- Virtualbox Serial Passthrough
- Virtualbox Serial Port Connection Refused
- Virtualbox Serial Port Setup
You can add up to four serial (COM) ports to a virtual machine. Virtual serial ports can output to physical serial ports, files, or named pipes.
You might want to add a virtual serial port to a virtual machine to make devices such as modems and printers available to the virtual machine. You can also use virtual ports to send debugging data from a virtual machine to the host system or to another virtual machine.


Sep 26, 2017 A virtual COM port or a virtual serial port is an ideal solution when a legacy software application expects a connection to a serial device port (COM port or COMM port) but cannot connect, due to a physical lack of available serial ports. Serial Ports Oracle VM VirtualBox supports the use of virtual serial ports in a virtual machine. Ever since the original IBM PC, personal computers have been equipped with one or two serial ports, also called COM ports by DOS and Windows. You are most probably absolutely right, since all the serial port connection encounters that I had, were instrument based, and they definitely like a line-based approach. As in: SNAP?1,2,4,10,11; 0x0a. They would definitely hang up if the termination character was not there, similar to an incomplete sentence. Jun 16, 2020 VirtualBox is an easy-to-configure solution that enables the guest to access the serial port. The only drawback is that there are multiple ways to accomplish this, which can be confusing. That’s the reason for this post, but before proceeding, let’s talk a little about serial ports. How Serial Ports are Named.
Power off the virtual machine.

Procedure
- Select the virtual machine and select VM > Settings.
- On the Hardware tab, click Add.
- In the Add Hardware wizard, select Serial Port.
- Click Finish to add the virtual serial port to the virtual machine.
- Select where the virtual serial port sends output. Option
Description Use a physical parallel port Send output to a physical serial port on the host system. Use output file Send output to a file on the host system. Either locate an existing output file or browse to a directory and type a filename to create a new output file. Output to named pipe Set up a direct connection between two virtual machines, or a connection between a virtual machine and an application on the host system. - If you selected Output to named pipe, configure the named pipe.
- (Windows host) Use the default pipe name, or type another pipe name. The pipe name must begin with .pipe and must be the same on both the server and the client.
- (Linux host) Type /tmp/socket or another UNIX socket name in the first text box. The pipe name must be the same on both the server and the client.
- To send debugging information to an application on the host system, select This end is the server from the first drop-down menu and select The other end is an application from the second drop-down menu.
- To send debugging information to another virtual machine, select This end is the server from the first drop-down menu and The other end is a virtual machine from the second drop-down menu.
- (Windows host) Use the default pipe name, or type another pipe name.
- To connect the port to the virtual machine when the virtual machine powers on, select Connect at power on.
- (Optional) On the Hardware tab, select the new serial port, select Yield CPU on poll, and click OK. This option is useful if you are using debugging tools that communicate over a serial connection. If the serial port in the guest operating system is being used in polled mode rather than interrupt mode, you might notice performance issues. This option forces the virtual machine to yield processor time if the only task it is trying to do is poll the virtual serial port.
If you set up a connection between two virtual machines, the first virtual machine is set up as the server. Repeat this procedure for the second virtual machine, but set it up as the client by selecting This end is the client when you configure the named pipe.
Serial port access is critically important in my role as an embedded software engineer. This is true no matter what operating system I am using and whether it is on a physical or virtual platform.
My main operating system is Windows XP, but many projects I am involved in require me to use Linux. This can be a problem as there are two reasons why I dislike having multiple computers running at the same time in my workspace. All the extra cables result in a tangled mess and I really like to leave the space open for other equipment like oscilloscopes that I need to complete my work.
To get around this issue, I installed Kubuntu as a guest OS on my Windows host machine. To perform debugging, access to the host’s serial port is required. VirtualBox is an easy to configure solution that enables the guest to access the serial port. The only drawback is that there are multiple ways to accomplish this, which can be confusing. That’s the reason for this post, but before proceeding, let’s talk a little about serial ports.
How Serial Ports are Named
Windows and Linux use very different naming conventions to identify serial ports. On a Windows machine, the ports are named COM1, COM2, etcetera. Linux uses a format of /dev/ttyS0, /dev/ttyS1, and so on. The example I will be discussing involves both operating systems. To avoid confusion over which port I am talking about, I will use COM1 on Windows and /dev/ttyS0 on Linux to map these names to the same IO ports and IRQs. COM2 will equate to /dev/ttyS1 and the pattern will be maintained for all of the serial ports I use.
Name Under Windows | Name Under Linux | IO Address | Interrupt Request (IRQ) |
COM 1 | /dev/ttyS0 | 3F8 | 4 |
COM 2 | /dev/ttyS1 | 2F8 | 3 |
COM 3 | /dev/ttyS2 | 3E8 | 4 |
COM 4 | /dev/ttyS3 | 2E8 | 3 |
Virtualbox Serial Port Settings
Setup & Requirements:
My computer has four serial ports which Windows defines as COM1, COM2, COM3, and COM4. The project requires that I attain access to COM3 from the Kubuntu guest installed under a VirtualBox virtual machine. I chose to use COM3 to avoid confusion, but any port can be accessed by using this method.
Virtualbox Com Port
VirtualBox Configuration:
Now we have to configure VirtualBox to connect the virtual serial port of the guest operating system to the host’s physical COM port. This is easy to do if you are aware of what to ignore when in VirtualBox’s serial port configuration dialog. When you first open the serial port configuration dialog box on the virtual machine, you will be presented with the Porto tab. We will be ignoring the IRQ, IO PORT, and Create Pipe fields.
- On the Porto Tab select the Enable Serial Port checkbox. This needs to be done before any other settings can be changed.
- Port Number: This field refers to the port number of the guest operating system. We want to map it to /dev/ttyS0, so COM1 should be selected. Remember, this does not refer to the machine’s physical ports.
- Port Mode: This parameter needs to be set to “Host Device” so we can connect a virtual port to a physical one.
- Port Path: The “Host Device” port mode field uses the physical device port number on the physical host. As previously mentioned, we will be connecting to COM3 so use that value here.
The screenshot below displays the Virtual Box Configuration.
Virtualbox Serial Port Connection Software
VirtualBox Serial Port Settings
Virtualbox Serial Passthrough
All you need to do is to set these three fields to your designated values and you are finished. Now it’s time to verify that the configuration works as intended. The Kubuntu virtual machine will map COM1, or the serial port with an I/O port of 0x3f8 and IRQ of 4 to /dev/ttyS0.
Virtualbox Serial Port Connection Refused
Verification Under Guest OS:
We need to use a serial port terminal on the guest operating system to verify our configuration. I have selected Cutecom to fill this role. We can perform the verification using two different methods.
- Short Pin 2 and 3 of the physical serial port. Doing this will short the serial port’s Rx and Tx pins. The result is that any data sent through the terminal will be echoed back to it.
- Connect...
Virtualbox Serial Port Setup
Read more »