28
  • I have no files or paths about usb on dev/
  • When I plug in a flash disk, nothing appears on dev/ or mnt/ or media/ about it.
  • sudo lsusb returns:

    unable to initialize libusb: -99
    

What should i do to enable usb access on bash?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
bcan
  • 505
  • 1
  • 4
  • 14
  • The latest version of Windows 10 (mine is 10.0.16299.248) will automatically mount your external USB drives under `/mnt/` – MasterHD Feb 20 '18 at 12:10
  • Full USB device support is still on plan. You can vote for it on [WSL UserVoice](https://wpdev.uservoice.com/forums/266908-command-prompt-console-windows-subsystem-for-l/suggestions/16759696-add-usb-device-support) – Leslie N Jan 18 '19 at 15:28
  • WSL UserVoice has shut down, new issue is https://github.com/microsoft/WSL/issues/2195 – parsley72 Oct 26 '19 at 00:49

3 Answers3

44

Good news, it is now possible to mount USB media (including FAT formated) and network shares with drvfs on Windows 10:

Mount removable media: (e.g. D:)

$ sudo mkdir /mnt/d
$ sudo mount -t drvfs D: /mnt/d

To safely unmount

$ sudo umount /mnt/d

You can also mount network shares without smbfs:

$ sudo mount -t drvfs '\\server\share' /mnt/share

You need at least Build 16176 so you might have to opt-in to the Windows Insider programm and then update Windows. Source: https://blogs.msdn.microsoft.com/wsl/2017/04/18/file-system-improvements-to-the-windows-subsystem-for-linux/

user643011
  • 2,163
  • 3
  • 21
  • 38
  • 4
    I mounted the D: drive as described and it silently returned me a prompt, but alas there is nothing there (no data in /mnt/d). umount says nothing mounted. Hmmm.. how do you know what the current build is? – wcochran May 22 '17 at 01:35
  • To get the current build number open the `cmd` command prompt and type `ver`. It should report `Microsoft Windows [Version 10.0.16176]` or newer. If not opt into Windows Insider program. Hope this helps! – user643011 May 22 '17 at 06:14
  • 2
    How can I mount other hardware that is not a drive? – cweitat Jun 08 '18 at 06:03
  • @cweitat: Currently not possible. Upvote those issues: https://wpdev.uservoice.com/forums/266908-command-prompt-console-windows-subsystem-for-l/suggestions/31920928-add-libusb-support-to-wsl https://wpdev.uservoice.com/forums/266908-command-prompt-console-windows-subsystem-for-l/suggestions/16759696-add-usb-device-support – user643011 Jan 19 '19 at 07:45
13

Edit:
According to a blog post from Microsoft this feature is now fixed from build 16176 and forward.

https://blogs.msdn.microsoft.com/wsl/2017/04/18/file-system-improvements-to-the-windows-subsystem-for-linux/

There is no USB support at the moment. Only fixed disks will be mounted (automatically) in /mnt.

Also other storage (other than auto-mounted fixed disks) are not supported, This includes CD-ROM drives, loopback devices and network shares.

Here is a link to the developer feedback page: Unable to access USB devices from bash

Patrik
  • 316
  • 3
  • 13
  • Does this mean SCP transfer will not work too? e.g. transfering files to beaglebone or other embedded devices etc. – bcan Aug 17 '16 at 05:48
  • SCP works just fine. It's only access to non fixed windows drives that's not working yet. – Patrik Aug 17 '16 at 09:59
  • 1
    Slight work-around: If you connect your board to your PC, you can sync files with Windows, and use Bash on your PC to access the same files in your Windows filesystem! – Rich Turner Nov 11 '16 at 01:16
  • They must've fixed it because I'm using build 16299, and my external USB drive (exFAT) is automatically mounted. – MasterHD Feb 20 '18 at 12:13
0

While it is possible to mount a drive using WSL 2, support for connecting USB devices to WSL, like a flash drive or SD card reader, is not natively supported in WSL.

Connecting USB devices to WSL IS now supported using the USBIPD-WIN opensource project however. To connect a USB device to a Linux distribution running via WSL 2:

  1. Install the USBIPD-WIN project (download and run the usbipd-win_x.msi installer file).
  2. Install the USBIP tools and hardware database by opening your distro (ie Ubuntu) and running sudo apt install linux-tools-5.4.0-77-generic hwdata.
  3. Edit the /etc/sudoers file associated with your Linux distro to allow permission: sudo visudo and then find the secure_path section, at the beginning of the path section, add the tools location: /usr/lib/linux-tools/5.4.0-77-generic.
  4. Ensure that a WSL command line is open (so the VM is active) and attach your USB device.
  5. Open PowerShell and list USB devices attached to your Windows machine with the command: usbipd wsl list.
  6. Select the bus ID of the device you’d like to attach to WSL and run this command: usbipd wsl attach --busid <busid>.
  7. Open Ubuntu (or your preferred WSL command line) and list attached USB devices: lsusb.

You should see the device you just attached and be able to interact with it using normal Linux tools. Depending on your application, you may need to configure udev rules to allow non-root users to access the device.

MWOJO
  • 336
  • 3
  • 7