Programming Note

WSL에 USB 장치 연결하기

Jeyeon 2026. 3. 10. 11:31
반응형

필자는 개발자로 회사에서 근무하고 있는데 윈도우 PC 환경에서 개발을 하다보니 WSL을 거의 필수적으로 설치해서 사용한다.

평소 같이 일을 하다가 WSL에 있는 파일을 USB로 옮겨 저장하려고 했다.

root@DESKTOP:~# ls -al /mnt
total 8
drwxr-xr-x  6 root root 4096 Mar 10 10:44 .
drwxr-xr-x 22 root root 4096 Mar 10 10:00 ..
drwxrwxrwx  1 root root 4096 Mar 10 09:52 c
drwxrwxrwx  1 root root  512 Mar 10 09:52 d
drwxrwxrwt  2 root root   60 Mar 10 09:55 wsl
drwxrwxrwt  7 root root  300 Mar 10 10:00 wslg

 

컴퓨터에 기본적으로 잡혀있던 C, D 드라이브는 /mnt 폴더에 잘 마운트가 되어있길래 USB를 꽂으면 WSL이 아주 똑똑하게 mnt 폴더에 마운트를 해주는 줄 알았는데 아니였다.

그럼 디스크가 인식은 되어있나 하고 확인을 해보았다.

root@DESKTOP:~# fdisk -l
...

Disk /dev/sdc: 2 GiB, 2147487744 bytes, 4194312 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/sdd: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

 

WSL에는 USB 장치가 아예 WSL에서 잡혀있질 않았다.

해결 방법

일단 자료를 찾아보니 Microsoft에서 WSL에 USB 장치를 연결하는 가이드를 제공하고 있었다.

 

Connect USB devices

Learn how to connect a USB device to your WSL 2 Linux distribution using usbipd-win.

learn.microsoft.com

usbipd 라는 유틸리티를 WSL을 구동하는 호스트 윈도우에 설치하고 사용하면 된다고 한다.

 

usbipd를 사용하기 위한 시스템 요구사항도 안내하고 있는데 아래와 같다.

  • 윈도우 11 이상 (Build 22000 이상). (Windows 10도 지원 가능하며 가이드 본문 참고)
  • x64 or ARM64 프로세서 (x86 프로세서는 지원하지 않음)
  • WSL이 최신 버전으로 설치 및 설정.
  • WSL 2로 Linux 배포판이 설치.

일단, 요구사항이라고는 하지만 문제 해결 방법을 찾으러 들어와 본문을 읽고 계신 분들이라면 위 사항은 당연히 만족할 것이라 본다.

 

이제 설치해보자.

윈도우 Powershell에서 winget 명령어를 이용하여 설치할 수 있다.

winget install --interactive --exact dorssel.usbipd-win

 

설치창이 나타나면 다음 버튼을 누르며 설치를 완료해주면 된다.

그 후 재부팅한다.

 

재부팅 후에 Powershell을 관리자 권한으로 실행한 후 아래 명령어를 입력하여 USB 장치 목록을 확인해보자.

PS C:\WINDOWS\system32> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-1    5986:2142  Integrated Camera, Integrated IR Camera, APP Mode             Not shared
2-2    0634:5603  UAS(USB Attached SCSI) 대용량 저장 장치                       Not shared
5-2    346d:5678  USB 대용량 저장 장치                                          Not shared
5-3    06cb:00f9  Synaptics UWP WBDI                                            Not shared
6-1    10ab:9309  Qualcomm FastConnect 6900 Bluetooth Adapter                   Not shared
6-2    2ce3:9563  Alcorlink USB Smart Card Reader                               Not shared

Persisted:
GUID                                  DEVICE

 

여기서 필자가 WSL에 연결할 항목은 "USB 대용량 저장 장치"이다. (UAS는 대부분 외장 하드/SSD이다.)

이 장치를 "공유 상태" 로 변경하기 위해 아래 명령어를 입력한다.

PS C:\WINDOWS\system32> usbipd bind --busid 5-2

 다시 장치 목록을 확인해보면 아래와 같이 USB 대용량 저장 장치가 공유 상태로 변경된 것을 확인할 수 있다.

PS C:\WINDOWS\system32> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-1    5986:2142  Integrated Camera, Integrated IR Camera, APP Mode             Not shared
2-2    0634:5603  UAS(USB Attached SCSI) 대용량 저장 장치                       Not shared
5-2    346d:5678  USB 대용량 저장 장치                                          Shared
5-3    06cb:00f9  Synaptics UWP WBDI                                            Not shared
6-1    10ab:9309  Qualcomm FastConnect 6900 Bluetooth Adapter                   Not shared
6-2    2ce3:9563  Alcorlink USB Smart Card Reader                               Not shared

Persisted:
GUID                                  DEVICE

이제 아래 명령어를 입력하여 WSL에 연결해보자.

PS C:\WINDOWS\system32> usbipd attach --wsl --busid 5-2
usbipd: info: Using WSL distribution 'ubuntu' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Loading vhci_hcd module.
usbipd: info: Detected networking mode 'nat'.
usbipd: info: Using IP address ###.###.###.### to reach the host.
이때 만약 usbipd: error: There is no WSL 2 distribution running; keep a command prompt to a WSL 2 distribution open to leave it running. 라고 에러가 나온다면 WSL이 안켜져있는 것이다. WSL을 켜고 다시 해보면 된다.

 

USB 장치가 WSL에 잘 연결됐다면 윈도우 환경에서 해당 USB는 연결이 끊긴 것으로 보여야 한다.

이제 WSL 환경에서 USB 장치가 연결됐는지 확인해보자.

root@DESKTOP:~# fdisk -l
...

Disk /dev/sdd: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/sde: 3.75 GiB, 4026531840 bytes, 7864320 sectors
Disk model: ProductCode
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

 

/dev/sde 라는 이름으로 잘 인식된 모습이다!

이제 해당 디스크를 폴더에 마운트만 해주면 확인할 수 있다. 필자는 다른 디스크 위치와 통일하기 위해 /mnt/e 디렉토리로 마운트를 하였다.

root@DESKTOP:~# mkdir /mnt/e
root@DESKTOP:~# sudo mount -o utf8 /dev/sde /mnt/e

옵션에 utf8을 주어서 혹시나 디렉토리/파일 명에 한글이 있더라도 깨지지 않게 마운트했다.

root@DESKTOP-O55D1T6:~# ls -al /mnt/e
total 28
drwxr-xr-x 7 root root 4096 Jan  1  1970  .
drwxr-xr-x 7 root root 4096 Mar 10 11:27  ..
drwxr-xr-x 5 root root 4096 Dec 16 08:52  .Trash-1000
drwxr-xr-x 3 root root 4096 Sep 25 01:01  NPKI
drwxr-xr-x 2 root root 4096 Jan 19 22:32 'System Volume Information'
drwxr-xr-x 2 root root 4096 Dec 23 09:08  **Masked directory name**
drwxr-xr-x 8 root root 4096 Dec 23 22:36  **Masked directory name**

 

폴더와 파일들도 잘 보이는 것을 확인했다!

 

만약 WSL에서 USB를 모두 사용했다면 우선 리눅스에서 마운트를 해제한다.

root@DESKTOP-O55D1T6:~# umount /mnt/e

그 후 윈도우에서 usbipd를 이용해 detach한다.

PS C:\WINDOWS\system32> usbipd detach --busid 5-2

그러면 다시 윈도우에서 해당 USB를 인식할 수 있게 된다.

반응형