I wrote this post to share my experience setting my HP Printer on WSL2 on Windows 11.
I followed the steps described at Connecting USB devices to WSL.
The first step is download the latest release of usbip-win.
Run the usbipd-win_2.1.0.msi installer and click on Install:
The setup is quick and simple:
On WSL 2, I am using Ubuntu 20.04, run the following commands to install usbip:
sudo apt install linux-tools-5.4.0-77-generic hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/5.4.0-77-generic/usbip 20
I am using a HP Deskjet 3776 printer:
Run a command prompt on Windows as administrator, I am using Windows Terminal, and run the following command to list all the USB devices connected on Windows:
usbipd wsl list
So far, it is possible to see that I don't have any USB device attached on WSL and that the USB/IP for my printer is 1-5:
I run the following command to attach my printer to WSL:
usbipd wsl attach --busid 1-5
Run again the usbipd wsl list command and observe that the printer is attached to WSL:
As I am using Windows Terminal, I can easily split verticaly my Windows command line with Ubuntu by click on profiles and pressing Alt+Click on Ubuntu profile:
Run the following command on WSL to list the USB devices:
lsusb
Notice that the printer device is listed on WSL:
The primary mechanism for Ubuntu printing and print services is the Common UNIX Printing System (CUPS). This printing system is a freely available, portable printing layer which has become the new standard for printing in most Linux distributions. More details at CUPS - Print Server.
Run the following commands to install CUPS:
sudo apt-get update
sudo apt-get install cups –y
The next step is start the printer server:
sudo sudo /etc/init.d/cups start
Run the following commands to download the HP setup:
sudo apt install hplip hplip-gui
Run the following command to launch the HP setup:
sudo hp-setup -b usb
On the following UI, select the third option to set up a wireless printer that requires a temporary USB connection and click Next:
Click on Next to proceed:
Observe that the USB printer is displayed in the devices list. Select the printer and click on Next:
Set up will configure the wireless network printer:
Copy the printer IP address that will be used later:
Before proceeding, I just realized that I need to start the D-Bus service:
sudo sudo /etc/init.d/dbus start
Now, run the following command to finish the printer setup using the IP address provided previously:
sudo hp-setup 192.168.15.111
Here it is possible to change the default printer name in case you want. Click Add Printer to complete the setup:
That is all set. Just to test, on Chromium web browser for Ubuntu, I can see my printer and print from WSL.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.