Is usb supported on Bash on Ubuntu on Windows 10? [closed]
Asked Answered
H

3

29
  • 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?

Harney answered 15/8, 2016 at 12:0 Comment(3)
The latest version of Windows 10 (mine is 10.0.16299.248) will automatically mount your external USB drives under /mnt/<drive letter>Abb
Full USB device support is still on plan. You can vote for it on WSL UserVoiceEkg
WSL UserVoice has shut down, new issue is github.com/microsoft/WSL/issues/2195Brickbat
P
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/

Phobia answered 16/5, 2017 at 12:41 Comment(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?Pluri
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!Phobia
How can I mount other hardware that is not a drive?Ionosphere
@cweitat: Currently not possible. Upvote those issues: wpdev.uservoice.com/forums/… wpdev.uservoice.com/forums/…Phobia
R
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

Rothrock answered 16/8, 2016 at 10:57 Comment(4)
Does this mean SCP transfer will not work too? e.g. transfering files to beaglebone or other embedded devices etc.Harney
SCP works just fine. It's only access to non fixed windows drives that's not working yet.Rothrock
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!Hatcher
They must've fixed it because I'm using build 16299, and my external USB drive (exFAT) is automatically mounted.Abb
C
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.

Cutie answered 15/11, 2021 at 22:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.