Linux on Windows with WSL

[1] The Windows Subsystem for Linux (WSL) lets developers use Linux applications, utilities, and Bash command-line tools directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

Note

These instructions are for Ubuntu

Prerequisites

You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11

Open PowerShell or Windows Command Prompt in administrator mode.

Install WSL

wsl --install

Check WSL version

New Linux installations, installed using the wsl –install command, will be set to WSL 2 by default.

wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu                 Running         2

Update

Update previously installed Linux distributions from WSL 1 to WSL 2 and update your WSL version to the latest version.

wsl --set-default-version 2
wsl --update

Connect USB devices [2]

Install the USBIPD-WIN project

Support for connecting USB devices is not natively available in WSL, so you will need to install the open-source usbipd-win project.

Install usbipd-win: https://github.com/dorssel/usbipd-win/releases

Once the USB/IP project has completed installing, you will need to install the user space tools and a database of USB hardware identifiers. Open a WSL command line window. You’ll be prompted by WSL for a password to run a sudo command.

sudo apt-get update
sudo apt install linux-tools-generic hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20

Attach a USB device

Note

Before attaching your USB device, ensure that a WSL command line is open. This will keep the WSL 2 lightweight VM active.

List all of the USB devices connected to Windows

usbipd wsl list
BUSID  VID:PID    DEVICE                                                        STATE
...
2-2    0483:df11  DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000        Not attached
...

Select the bus ID of the device you’d like to attach to WSL and run this command. You’ll be prompted by WSL for a password to run a sudo command. The Linux distribution to be attached must be your default distribution.

usbipd wsl attach -a --busid 2-2