Cookie
FlexiHub Team uses cookies to personalize your experience on our website. By continuing to use this site, you agree to our cookie policy. Click here to learn more.
Olga Weis Olga Weis Last updated May 15, 2024

VirtualBox COM Port Passthrough: Definitive Guide

Nowadays there isn’t as much use for COM ports as it once was. And yet, they still can find their practical application and do you a great deal of good.

For example, you’ve got to have at least one serial port or you won’t be able to interact with the vast majority of the kernel debugging tools. In actual practice, it doesn’t have to be a physical COM-port. With the right software tool, you might as well do kernel debugging through a virtual serial port on a virtual machine.

This tutorial will show you how to redirect a serial port from the host to a guest VM in VirtualBox and how to create virtual serial ports in VirtualBox.

Access serial ports in VirtualBox

FlexiHub
4.8 Rank based on 386+ Reviews
FlexiHub

A very easy method of implementing VirtualBox serial port passthrough is with the software tool FlexiHub.

FlexiHub offers users a simple path to enable serial ports in VirtualBox or any other virtualization platform by redirecting serial port devices to guest virtual machines over the network.

FlexiHub works by creating virtual connections and redirecting serial port data over a network to the VirtualBox virtual machines. There are no complex parameters to configure. With FlexiHub, you can add a VirtualBox serial port with just one click.

How to share COM ports to VirtualBox

  • 1.
    Register a FlexiHub account and start a free demo evaluation.
    Register a FlexiHub profile
  • 2.
    Install FlexiHub on the VirtualBox host with a physical serial port that will be redirected. After that, install FlexiHub on the VirtualBox virtual machine that will connect to the host’s serial port.
    Download Flexihub
  • 3.
    Launch the app both on the host and guest VM and log into your account.
    Login flexihub
  • 4.
    The serial devices that are available for connection will be displayed in the FlexiHub’s interface.
    FlexiHub’s interface
  • 5.
    On the guest machine, click ‘Connect’ in the app’s interface to access a serial port in VirtualBox.
    access a serial port
From this point on, serial devices connected to the VirtualBox serial ports will be redirected to the virtual environment without any extra configuration.
For the video instructions on how to share serial ports to VirtualBox, you can check out this brief guide:

How to Set Up Serial Ports in Oracle VM VirtualBox

Setting up serial ports in Oracle VM VirtualBox can be a handy feature, especially for specific tasks like kernel debugging or when you need to connect devices that traditionally used serial connections. Here’s a straightforward guide to help you configure and use virtual serial ports in VirtualBox.
  • 1.
    Step 1: Accessing the Settings

    Via VirtualBox GUI: Go to the settings of your virtual machine. Look for the "Serial Ports" tab.

    Via Command Line: Use the `VBoxManage modifyvm` command. Detailed usage can be found in the VirtualBox manual under Section 7.8, “VBoxManage modifyvm”.
  • 2.
    Step 2: Configuring Your Serial Ports

    You can configure up to four serial ports for each virtual machine.

    1. Port Number: Assign a port number (COM1, COM2, COM3, COM4) with specific I/O bases and IRQs:
    • COM1: I/O base 0x3F8, IRQ 4
    • COM2: I/O base 0x2F8, IRQ 3
    • COM3: I/O base 0x3E8, IRQ 4
    • COM4: I/O base 0x2E8, IRQ 3
    • You can also specify custom I/O bases and IRQs if needed.


    2. Port Mode: Decide how the virtual serial port will connect to the host or other VMs:
    • Disconnected: Acts like it's unplugged.
    • Host Device: Links the VM’s port to a physical serial port on your host machine.
    • Host Pipe:

      - For Windows: Uses a named pipe (e.g., `\\.\pipe\name`).
      - For macOS/Linux: Uses a local domain socket (usually in `/tmp`).

    • Raw File: Outputs the serial data to a file on your host.
    • TCP Socket:

      - TCP Server: Allows remote connections to this port over the network.
      - TCP Client: Connects to another server over the network.
  • 3.
    Step 3: Implementing the Configuration
    • Set up each port according to your requirements using either the GUI or the VBoxManage commands. For example:

    • To set COM1 as a TCP Server, use:
      VBoxManage modifyvm "VM name" --uart1 0x3F8 4 --uartmode1 tcpserver 2023

    • To connect COM2 to a host device on a Windows host:
      VBoxManage modifyvm "VM name" --uart2 0x2F8 3 --uartmode2 hostdevice "\\.\COM1"
  • 4.
    Step 4: Verifying the Setup
    • Start your virtual machine and check the device manager or equivalent to verify that the serial ports are recognized and configured correctly.

Additional Tips

✦ Remember that serial ports configured to use the same IRQ must not be used simultaneously due to sharing issues.

✦ For advanced setups like kernel debugging or simulating a null-modem connection between VMs, refer to specific configurations relevant to your use case.

This guide should help you effectively utilize virtual serial ports in VirtualBox, enhancing your VM's connectivity for development, debugging, or legacy device interactions.

VirtualBox COM Port Passthrough
  • 4.8 overall rank based on 386+ Reviews
  • Windows, macOS, Linux, Android and Raspberry Pi.
  • 10.76MB Size.
  • Version 7.0.15125. (3 Jun, 2024).
  • Pricing starts $14 per month billed annually