Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't see USB in lsblk #8541

Closed
1 of 2 tasks
isaacdchan opened this issue Jun 23, 2022 · 5 comments
Closed
1 of 2 tasks

Can't see USB in lsblk #8541

isaacdchan opened this issue Jun 23, 2022 · 5 comments

Comments

@isaacdchan
Copy link

Version

Microsoft Windows [Version 10.0.22000.739]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.102.1-microsoft-standard-WSL2

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

I followed this instruction to get my USB seen by WSL2:
https://github.com/dorssel/usbipd-win

PS C:\Users\isaac> usbipd wsl list
>>
BUSID  VID:PID    DEVICE                                                        STATE
1-4    046d:0892  HD Pro Webcam C920                                            Not attached
1-12   8087:0aa7  Intel(R) Wireless Bluetooth(R)                                Not attached
1-19   1058:0730  USB Mass Storage Device                                       Attached - Ubuntu-20.04
5-6    931c:6c65  USB Input Device                                              Not attached
6-1    b58e:9e84  Yeti Classic, USB Input Device                                Not attached
6-2    046d:c539  USB Input Device                                              Not attached
6-4    04d9:0192  USB Input Device                                              Not attached
7-4    043e:9a8a  USB Input Device                                              Not attached
❯ lsusb
Bus 002 Device 002: ID 1058:0730 Western Digital Technologies, Inc. My Passport Essential (WDBACY)
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Expected Behavior

I'd expect Device 002 to show up as a block device when running lsblk

Actual Behavior

❯ lsblk
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda    8:0    0   256G  0 disk
sdb    8:16   0 339.8M  1 disk
sdc    8:32   0   256G  0 disk /

Diagnostic Logs

No response

@elsaco
Copy link

elsaco commented Jun 23, 2022

@isaacdchan the current WSL kernel is built with CONFIG_USB_STORAGE is not set. This option needs to be enabled in order to mount USB flash drives and show in lsblk output.

@isaacdchan
Copy link
Author

isaacdchan commented Jun 23, 2022

@elsaco is there a official MSFT guide on how to simply do this?

I wish there was a flag I could set when running wsl --install to enable this feature. Is there a reason why this feature is disabled by default?

I saw that someone wrote this guide but it seems very complicated

@elsaco
Copy link

elsaco commented Jun 23, 2022

MS is using a different approach to share USB devices in WSL, USB over IP with the usbipd daemon running on host. Since this is usbip it works both ways, a WSL client can attach a remote device also.

To get support for USB storage devices 5.10.102.1 kernel needs to be rebuild. However, if you don't want to go this route I could share a kernel built with USB storage support. This is a diff between the custom kernel config and https://github.com/microsoft/WSL2-Linux-Kernel/blob/linux-msft-wsl-5.10.y/Microsoft/config-wsl:

diff config config-wsl
5c5
< CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0"
---
> CONFIG_CC_VERSION_TEXT="x86_64-msft-linux-gcc (GCC) 9.3.0"
7c7
< CONFIG_GCC_VERSION=90400
---
> CONFIG_GCC_VERSION=90300
11,12d10
< CONFIG_CC_CAN_LINK=y
< CONFIG_CC_CAN_LINK_STATIC=y
24c22
< CONFIG_LOCALVERSION="-custom-WSL2"
---
> CONFIG_LOCALVERSION="-microsoft-standard-WSL2"
748a747
> # CONFIG_GCC_PLUGINS is not set
2418,2433c2417
< CONFIG_USB_STORAGE=y
< # CONFIG_USB_STORAGE_DEBUG is not set
< # CONFIG_USB_STORAGE_REALTEK is not set
< # CONFIG_USB_STORAGE_DATAFAB is not set
< # CONFIG_USB_STORAGE_FREECOM is not set
< # CONFIG_USB_STORAGE_ISD200 is not set
< # CONFIG_USB_STORAGE_USBAT is not set
< # CONFIG_USB_STORAGE_SDDR09 is not set
< # CONFIG_USB_STORAGE_SDDR55 is not set
< # CONFIG_USB_STORAGE_JUMPSHOT is not set
< # CONFIG_USB_STORAGE_ALAUDA is not set
< # CONFIG_USB_STORAGE_ONETOUCH is not set
< # CONFIG_USB_STORAGE_KARMA is not set
< # CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
< # CONFIG_USB_STORAGE_ENE_UB6250 is not set
< # CONFIG_USB_UAS is not set
---
> # CONFIG_USB_STORAGE is not set
3541c3525,3531
< # CONFIG_DEBUG_INFO is not set
---
> CONFIG_DEBUG_INFO=y
> # CONFIG_DEBUG_INFO_REDUCED is not set
> # CONFIG_DEBUG_INFO_COMPRESSED is not set
> # CONFIG_DEBUG_INFO_SPLIT is not set
> # CONFIG_DEBUG_INFO_DWARF4 is not set
> CONFIG_DEBUG_INFO_BTF=y
> # CONFIG_GDB_SCRIPTS is not set

Nothing different beside CONFIG_USB_STORAGE=y and CONFIG_DEBUG_INFO=n

@isaacdchan
Copy link
Author

Got it. Thanks for the info @elsaco. So it should be as simple as

  1. Cloning the kernel git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
  2. Modifying WSL2-Linux-Kernel/Microsoft/config-wsl
  3. Running sudo make $new_config
  4. Copy the kernel to windows host
  5. Create C:\\Users\\ischan\\.wslconfig which points to new kernel
[wsl2]
kernel=C:\\Users\\your-user-name\\bzImage
swap=0
localhostForwarding=true
  1. Restart wsl

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants