# Accéder à une clef USB sur WSL2

**URL:** <https://www.debian-fr.org/t/acceder-a-une-clef-usb-sur-wsl2/85773>\
**Category:** Support Debian\
**Created:** [Décembre 7, 2021, 2:49 UTC](https://www.debian-fr.org/t/acceder-a-une-clef-usb-sur-wsl2/85773 "2021-12-07T14:49:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiye](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/k/90db22/32.png) [@kiye](https://www.debian-fr.org/u/kiye)\
**Post date:** [Décembre 7, 2021, 2:49 UTC](https://www.debian-fr.org/t/acceder-a-une-clef-usb-sur-wsl2/85773/1 "2021-12-07T14:49:44Z")

</div>

Bonjour à tous,  
j’ai debian 10 d’installée sur WSL2 . J’aimerais maintenant décrypter une clef USB chiffrée LUKS.

Mon problème est d’accéder à la clé USB. J’ai donc installé usbip hwdata et usbutils.

Avant d’insérer la clef usb, je lance lsusb sur WSL:

```nohighlight
# lsusb
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

```

J’insère la clef USB (64Go).  
J’ouvre powerShell en mode administrateur et j’exécute ‹&nbsp;usbipd wsl list&nbsp;›:

```nohighlight
PS C:\WINDOWS\system32> usbipd wsl list
	BUSID DEVICE STATE
	1-1 Dispositif de stockage de masse USB Not attached
	1-3 Souris USB Microsoft Hardware Not attached
	1-5 Goodix fingerprint Not attached
	1-6 Integrated Webcam Not attached
	1-10 Intel(R) Wireless Bluetooth(R) Not attached

```

La clef USB a le busid n°1-1

je l’attache à WSL:

```nohighlight
usbipd wsl attach --busid 1-1

```

Sous WSL, `udevadm monitor` voit l’attachement de la clef usb:

```nohighlight
KERNEL[3418.705250] add /devices/platform/vhci_hcd.0/usb1/1-1 (usb)
KERNEL[3418.707326] add /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0 (usb)
KERNEL[3418.707799] bind /devices/platform/vhci_hcd.0/usb1/1-1 (usb)

```

je relance lsusb:

```nohighlight
# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

```

La device correspondant à la clef USB apparaît bien, tout va bien jusqu’à présent.

je m’attends à voir apparaitre le device sdX correspondant au block mass storage de la clef USB dans la liste lsblk

```nohighlight
# 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 /

```

Et là déception, je ne vois pas ma clef USB de 64Go, je ne peux donc pas lancer le déchiffrage.  
Comment faire apparaitre le clef en tant que device block?

---

<div class="post-metadata">

**Author:** ![kiye](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/k/90db22/32.png) [@kiye](https://www.debian-fr.org/u/kiye)\
**Post date:** [Décembre 10, 2021, 3:22 UTC](https://www.debian-fr.org/t/acceder-a-une-clef-usb-sur-wsl2/85773/2 "2021-12-10T15:22:21Z")

</div>

J’ai regardé la config kernel de WSL2 : [WSL2-Linux-Kernel/config-wsl at master · microsoft/WSL2-Linux-Kernel · GitHub](https://github.com/microsoft/WSL2-Linux-Kernel/blob/master/Microsoft/config-wsl)

Et , consternation: # CONFIG\_USB\_SUPPORT is not set  
Donc la config «&nbsp;USB Mass Storage support&nbsp;» n’est pas activé  
Ceci explique mon problème. Il n’y a pas 36 solutions, il faut activer la config et recompiler le noyau.  
Avant, installer les outils nécessaire:

```auto
$ apt install build-essential flex bison libssl-dev libelf-dev libncurses5-dev git bc

```

Installation de pahole version \> 1.16

```auto
$ wget http://archive.ubuntu.com/ubuntu/pool/universe/d/dwarves-dfsg/dwarves_1.17-1_amd64.deb
$ dpkg -i dwarves_1.17-1_amd64.deb

```

Cloner le WSL2 kernel:

```auto
$ git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
$ cd WSL2-Linux-Kernel

```

Activer la config USB Mass Storage:

```auto
$ export KCONFIG_CONFIG=Microsoft/config-wsl
$ make menuconfig

```

Device Drivers —\>  
[_] USB support (NEW) —\>  
\<_\> USB Mass Storage support

Compiler le kernel

```auto
$ make KCONFIG_CONFIG=Microsoft/config-wsl -j8

```

Copier le kernel sur le FS Windows

```auto
$ cp arch/x86/boot/bzImage /mnt/c/Users/<UserName>/kernel

```

Créer le fichier de config : `/mnt/c/Users/<UserName>/.wslconfig` avec comme contenu:

```auto
[wsl2]
kernel=C:\\Users\\<UserName>\\kernel

```

Puis redémarrer WSL avec PowerShell pour prendre en compte le nouveau kernel:

```auto
PS C:\WINDOWS\system32> wsl --shutdown

```

Pour finir, on recommence les manip explicité dans mon 1er commentaire ci dessus et ça marche:

```auto
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 344.9M 1 disk
sdb 8:16 0 2G 0 disk [SWAP]
sdc 8:32 0 256G 0 disk /
sdd 8:48 1 60.6G 0 disk
└─sdd1 8:49 1 60.6G 0 part

```

la clef USB est accessible sous /dev/sdd1 🙂

---

<div class="post-metadata">

**Author:** ![Clochette](https://www.debian-fr.org/user_avatar/www.debian-fr.org/clochette/32/8757_2.png) [@Clochette](https://www.debian-fr.org/u/Clochette)\
**Post date:** [Décembre 10, 2021, 3:30 UTC](https://www.debian-fr.org/t/acceder-a-une-clef-usb-sur-wsl2/85773/3 "2021-12-10T15:30:19Z")

</div>

La source ici : [https://github.com/jovton/USB-Storage-on-WSL2](https://github.com/jovton/USB-Storage-on-WSL2)
