10 WSL - Jubijub/arch-config GitHub Wiki
This section contains any WSL specific configuration. I use Arch within WSL as well.
https://gist.github.com/buswedg/270e7594a68ff99f2af659a97661eb5e : authorize Yubikey access in WSL
wsl --update
wsl --install archlinux
You will end up with a minimal Archlinux, logged as root.
pacman -S sudo neovim fish zsh sudo
Note
|
from recent WSL version onwards (tested with WSL 2.5.9.0 with kernel 6.6.87.2-1), there is no need to compile a custom kernel as the base kernel contains HID and HIDRAW modules.
|
This script runs USBIPD, detect which USB device is the Yubikey, and "attaches" it to ArchLinux in WSL.
Create the script G:\My Drive\Documents\PowerShell\YubiKeyAttachToWSL.ps1
(whichever path works, this one is on my Google drive).
$yubiKeyBusId = (usbipd list | Select-String "xxxx:xxxx" | ForEach-Object { $_.Line.Split()[0] })
if ($yubiKeyBusId) {
usbipd attach --wsl --busid $yubiKeyBusId
Write-Host "YubiKey attached to WSL with busid $yubiKeyBusId."
} else {
Write-Host "YubiKey not found."
}
-
Unplug / replug the YubiKey
-
Open the Event Viewer in Windows
-
In Event Viewer (Local) › Windows Logs › System, you should see Information level logs for
WudfUsbccidDrv
with an event ID 104 (also 105). -
Create a task via Right click › Attach Task To This Event….
-
Name: Any name you want
-
When an Event is Logged : keep default values
-
Log: System
-
Source: WudfUsbccidDrv
-
Event ID: 104
-
-
Action: Start a program
-
Program/script:
powershell.exe
-
Add arguments (optional) : -ExecutionPolicy Bypass -File "G:\My Drive\Documents\PowerShell\YubiKeyAttachToWSL.ps1"
-
-
Click on
Open the property file dialog for this task when finished
-
Edit the task as follows :
* Triggers
Edit the existing trigger, and add
* Delay task for: 5 seconds
Add a new triger At logon
* Specific user: <the current user>
* Delay task for: 5 seconds
* Settings
Enable the following settings
* ALlow task to be run on demand
* Run task as soon as possible after a scheduled start is missed
* Stop the task if it runs longer than 30 seconds
* If the running task does not end when requested, force it to stop
Still on Windows, Open the Task scheduler
:
* Open Task Scheduler(local) › Task Scheduler Library › Event Viewer Tasks
* You should see your newly created task there
-
You can run it manually first:
-
After 5sec, You should see a shell window popping briefly
-
On the history of the task in the Task manager, you should see a
Task completed
event following a event110 - Task triggered by user
-
paru -S usbutils (1)
lsusb
-
provides
lsusb
You should see something like
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 008: ID 1050:0407 Yubico.com Yubikey 4/5 OTP+U2F+CCID
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Warning
|
the 'non-root' rule has to have a name that comes before 73-seat-late.rules.in .
|
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0666", TAG+="uaccess", ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0407" #(1)
-
The rule should NOT add the device to the group
plugdev
, it uses correctly theudev
uaccess
tag instead, alongside the right mode.
-
Start by unpluging and replugging the key, then wait 10 sec.
-
Confirm that the key is visible as a USB device with
lsusb
-
launch
ykman info
: if all worked it should output information about the Yubikey
If you get ERROR: No YubiKey detected!
, something is wrong
Execute FIDO_DEBUG=1 fido2-token -L
.
run_manifest: found 1 hid device
run_manifest: found 0 nfc devices
fido_hid_unix_open: open /dev/hidraw0: Permission denied
fido_hid_unix_open: open /dev/hidraw1: Permission denied
Identify your webcam, and take note of the BUSID
You can do so directly with :
$logitechId = usbipd list | Where-Object { $_ -match "HD Pro Webcam C920" } | ForEach-Object { ($_ -split '\s+')[0] }
Bind the device to WSL :
usbipd bind -b $logitechId
usbipd attach -w -b $logitechId
lsusb (1)
-
should show the webcam in the list
sudo chmod 777 /dev/video*
-
Alternative, possibly cleaner approach: https://github.com/microsoft/WSL/issues/6999#issuecomment-2303010704
The workaround is to use tmfiles service to re-create the symlink to /mnt/wslg/.X11-unix
sudo nvim /etc/tmpfiles.d/wslg.conf
Add the following content :
# This file is part of the debianisation of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# See tmpfiles.d(5) for details
# Type Path Mode UID GID Age Argument
L+ /tmp/.X11-unix - - - - /mnt/wslg/.X11-unix
Reference: * https://github.com/PINTO0309/wsl2_linux_kernel_usbcam_enable_conf * https://medium.com/software-dev-explore/wsl2-webcam-23c1dc9408ae
uname -r -v
-
Open
C:\Users\<your_user>\.wslconfig
-
Comment the line starting with
kernel=<path to custom kernel>
if there is one-
If there was one, restart WSL, restart Arch and repeat
uname -r -v
to see which standard kernel version your WSL is using.
-
Warning
|
run the following commands with ZSH |
Check the tags available on Microsoft WSL kernel github, there should be one that matches your WSL version.
TAGVERNUM=5.15.153.1 \
&& TAGVER=linux-msft-wsl-${TAGVERNUM} \
&& WINUSERNAME=jubi
-
TAGVERNUM
should match youruname -r -v
-
WINUSERNAME
should match your windows user name, eg:c:\Users\jubi
cd /usr/src
sudo git clone --depth 1 -b ${TAGVER} \
https://github.com/microsoft/WSL2-Linux-Kernel.git \
${TAGVERNUM}-microsoft-standard \
&& cd ${TAGVERNUM}-microsoft-standard
sudo cp /proc/config.gz config.gz
sudo gunzip config.gz
sudo mv config .config
sudo make menuconfig
Make sure to activate the following options by selecting them and hitting SPACE.
# Build WSL2 kernel with usb camera support
# menuconfig -> Device Drivers -> Multimedia support -> Filter media drivers
# -> Device Drivers -> Multimedia support -> Media device types -> Cameras and video grabbers
# -> Device Drivers -> Multimedia support -> Video4Linux options -> V4L2 sub-device userspace API
# -> Device Drivers -> Multimedia support -> Media drivers -> Media USB Adapters -> USB Video Class (UVC)
# -> Device Drivers -> Multimedia support -> Media drivers -> Media USB Adapters -> UVC input events device support
# -> Device Drivers -> Multimedia support -> Media drivers -> Media USB Adapters -> GSPCA based webcams
Note
|
other recommended options here. I didn’t need all of those. |
sudo make -j$(nproc) KCONFIG_CONFIG=.config \
&& sudo make modules_install -j$(nproc) \
&& sudo make install -j$(nproc)
Note
|
you should end up with a large vmlinux file in the directory
/usr/src/${TAGVERNUM}-microsoft-standard
|
Warning
|
the make install will complain it doesn’t find lilo .
You can ignore this message.
|
Arch is installed in C:\ArchWSL\
so I put the kernel there
sudo rm /mnt/c/ArchWSL/vmlinux
sudo cp /usr/src/${TAGVERNUM}-microsoft-standard/vmlinux /mnt/c/ArchWSL/
Note
|
you don’t need to update any bootloader on WSL side. |