.. _wsl: 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 ----------- .. prompt:: :prompts: PowerShell> wsl --install Check WSL version ----------------- New Linux installations, installed using the *wsl --install* command, will be set to WSL 2 by default. .. prompt:: :prompts: PowerShell> wsl -l -v .. code-block:: text 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. .. prompt:: :prompts: PowerShell> 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 .. note:: In case you have used usbipd with WSL 2 before, the following has changed since version 4.0.0: - You have to share the device using usbipd bind first. - You no longer have to install any client-side tooling. - You no longer have to specify a specific distribution. - The syntax for the command to attach has changed slightly. 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 .. prompt:: :prompts: PowerShell> usbipd list .. code-block:: text 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. Before attaching the USB device, the command usbipd bind must be used to share the device, allowing it to be attached to WSL. This requires administrator privileges. Select the bus ID of the device you would like to use in WSL and run the following command. .. prompt:: :prompts: PowerShell> usbipd bind --busid 2-2 To attach the USB device, run the following command. (You no longer need to use an elevated administrator prompt.) Ensure that a WSL command prompt is open in order to keep the WSL 2 lightweight VM active. .. prompt:: :prompts: PowerShell> usbipd attach -a --wsl --busid 2-2 WSL NFS Server -------------- brief description how to share /nfsshare with everyone .. prompt:: :prompts: WSL bash $ sudo apt install nfs-kernel-server rpcbind sudo mkdir /nfsshare sudo chown nobody:nogroup /nfsshare sudo chmod 777 /nfsshare sudo sh -c "echo '/nfsshare *(rw,sync,no_subtree_check,insecure,no_root_squash)' >> /etc/exports" sudo service rpcbind start sudo service nfs-kernel-server start sudo exportfs -a IP address of your Linux distribution installed via WSL 2 (the WSL 2 VM address) .. prompt:: :prompts: PowerShell> wsl hostname -I Map ports 443, 2049 to WSL .. prompt:: :prompts: PowerShell> netsh interface portproxy add v4tov4 listenport=443 listenaddress=0.0.0.0 ` connectport=443 connectaddress=(wsl hostname -I) netsh interface portproxy add v4tov4 listenport=2049 listenaddress=0.0.0.0 ` connectport=2049 connectaddress=(wsl hostname -I) Add Firewall rules .. prompt:: :prompts: PowerShell> netsh advfirewall firewall add rule name="WSL NFS IN" dir=in ` action=allow protocol=TCP localport=111,2049 netsh advfirewall firewall add rule name="WSL NFS OUT" dir=out ` action=allow protocol=TCP localport=111,2049 .. [1] https://learn.microsoft.com/en-us/windows/wsl/install .. [2] https://learn.microsoft.com/en-us/windows/wsl/connect-usb