EST. 2026 — Notes from real server work SYSADMIN · SECURITY · AI · DIRECTADMIN Issue 01
THE SYSADMIN ALMANAC
Home / Linux / USB in WSL2 with usbipd-win — Real Hardware for Linux on Windows
Linux

USB in WSL2 with usbipd-win — Real Hardware for Linux on Windows

by Ton-Or ·11 Jul 2026·7 min read
USB in WSL2 with usbipd-win — Real Hardware for Linux on Windows

WSL2 can replace a physical Linux machine for almost everything, with one remaining barrier — USB devices. usbipd-win is the Microsoft-endorsed approach, passing serial adapters, dev boards, or dongles to Ubuntu in WSL so it can access them as if they were plugged into a physical machine

I had a firmware flashing job for a device whose toolchain was only available on Linux. The machine I was working on ran Windows — these days, WSL2 can replace a physical Linux machine for almost everything, except for the one thing I kept hitting a wall with: USB devices — plug in a serial adapter, dev board, dongle, or anything else, and Ubuntu in WSL cannot see it at all, because WSL2 is a VM without its own USB controller.

The Microsoft-endorsed solution is usbipd-win — it uses the USB/IP protocol to pass devices from Windows directly to the WSL kernel. All the values in this article come from my actual local work.

Device pathUSB devicePlugged into Windows→usbipd-winbind + attach→WSL2 kernelUSB/IP protocol→/dev/ttyUSB0Use as on a physical machine

Installation

On Windows (PowerShell as admin):

winget install usbipd

On Ubuntu in WSL — the userspace tools:

sudo apt install linux-tools-virtual hwdata usbutils
sudo update-alternatives --install /usr/local/bin/usbip usbip \
  $(ls /usr/lib/linux-tools/*/usbip | tail -1) 20

Actual use: 3 commands

1. See what is plugged in (PowerShell):

usbipd list
# BUSID  VID:PID    DEVICE                       STATE
# 1-3    0403:6001  USB Serial Converter          Not shared
# 1-5    2e8a:0003  RP2 Boot                      Not shared

2. Bind the device (only once per device — requires admin):

usbipd bind --busid 1-3

3. Attach it to WSL (no admin needed this time):

usbipd attach --wsl --busid 1-3

Check on Ubuntu:

lsusb
# Bus 001 Device 002: ID 0403:6001 Future Technology Devices FT232 Serial
dmesg | tail -3
# usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0

You get /dev/ttyUSB0 to use exactly as on a physical Linux machine — with minicom, esptool, openocd, or whatever you need.

When finished, return it to Windows:

usbipd detach --busid 1-3
usbipd unbind --busid 1-3   # ถ้าจะเลิกถาวร

Lessons from actual use

1. Unplugging drops the attachment — USB/IP is tied to the session, so if you unplug and reconnect, you need to attach again (the binding remains). For regular use, you can write a short PowerShell profile function to call:

function wsl-usb { usbipd attach --wsl --busid 1-3 }

2. Windows cannot use the device while it is attached — the entire device is handed over to WSL, rather than shared.

3. The CRLF trap when running bash through wsl.exe — this is not directly related to USB, but I ran into it during the same job:

Invisible CRLF

When sending a multi-line command from PowerShell into wsl -- bash -c "...", Windows CRLF line endings get carried into the bash string — variables containing paths end up with an invisible trailing \r, breaking the paths. The symptom is No such file or directory even though the file exists. To avoid this: always send a single-line command, or write a .sh file and run it through sed -i 's/\r$//' before executing it

4. Some USB networking devices take over the Windows default route — in my case, a USB modem (HiLink) was simply plugged in without a SIM. It presented itself as a network adapter and took over the default route — the whole machine lost internet access, which had me puzzled for quite a while. I fixed it by pushing that interface's metric way up:

# admin PowerShell — ดู ifIndex จาก Get-NetIPInterface ก่อน
Set-NetIPInterface -InterfaceIndex <idx> -InterfaceMetric 9999

Summary

usbipd-win lets WSL2 close the last gap with a physical Linux machine — the list -> bind (ครั้งเดียว) -> attach workflow is easy to remember and more stable in actual use than I expected. For embedded work/firmware flashing on Windows, I no longer need a separate Linux machine or a live USB.

These days, I keep Ubuntu running in WSL on my main Windows machine all the time. Whenever a job needs hardware access, I just attach the device as needed. If I have left anything out or made a typo, I will come back and fix it later.

Want us to set this up?

Get help with server setup, configuration, migration, or troubleshooting. Save time for the work that matters.

Get a quote

Hit something like this? Stuck somewhere?

Come trade notes on the LinuxThai board

→ Continue on the board

Comments 0

No comments yet — be the first