125

I'm using Windows 10's Ubuntu Bash shell. It maps the C drive fine as /mnt/c.

I have other local physical hard drives, mounted in Windows as E: and F:

How do I tell Bash to mount these drives too (ideally automatically at /mnt/e and /mnt/f, but manual mounting is fine)? "sudo fdisk -l" doesn't seem to work (cannot open /proc/partitions), so I'm not sure how to find their names, otherwise I'd just use a regular mount command.

3

6 Answers 6

152

Good news, it is now possible to mount USB media (including formatted as FAT) 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/

5
  • 2
    Hi David, thanks for your suggestion. Feel free to indicate duplication. This answer is well tailored to the question. Feel free to edit it if you can improve it or comment with suggestions if you don't have the reputation to do that.
    – user643011
    Commented May 16, 2017 at 19:35
  • 6
    The OPS asked "how do I mount...", so IMHO this is the answer I appreciated the most (and as a bonus, even offers the answer to mount network shares)
    – HidekiAI
    Commented Jul 11, 2017 at 16:28
  • 1
    Can this be made permanent? I have tried to follow guidance on modifying /etc/fstab for regular linux, but they don't seem to apply to WSL. Commented May 1, 2018 at 20:25
  • @AdamCrossland: That has been added recently. Check if you have at least Windows version 10.0.17093. Open a shell with "cmd" and run "ver" to check. If you have an older version you need to upgrade. You probably have to opt-in to Windows Insider updates first. Source: github.com/Microsoft/WSL/issues/2636#issuecomment-364172586
    – user643011
    Commented May 8, 2018 at 12:25
  • Found this in 2020. Is it reasonable to have a recurring script to check if a windows drive has been added, then run the linux command to mount the drive? this might be the solution. hoping someone with more experience in powershell & task scheduling can recognise if this is viable or best solution in 2020. superuser.com/questions/219401/… Commented Jan 1, 2020 at 22:26
16

To facilitate interoperability with Windows, WSL uses the DrvFs file system. WSL automatically mounts all fixed drives with supported file systems under /mnt, such as /mnt/c, /mnt/d, etc. Currently, only NTFS and ReFS volumes are supported.

From: https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/

If e: and f: have other filesystems like FAT, exFAT, they will not be automatically mounted.

3
  • Makes sense. Those drives are ext4 volumes and mounted using ext2fsd from ext2fsd.com and I never would have imagined they wouldn't be recognized by a Linux kernel. That explains why. Commented Oct 12, 2016 at 19:04
  • 1
    @JasonChampion: with Windows 10's Ubuntu Bash shell there is no Linux kernel. That's why it wouldn't work before.
    – user643011
    Commented Jul 12, 2017 at 16:19
  • @mementum but in my case the filesystem is ɴᴛꜰꜱ and it doesn’t mount anyway. Commented Mar 30, 2019 at 11:13
4

Those other drives should be there as well, in /mnt/e etc. You can check with ls /mnt. If they aren't, I'd try one of several things-

-Reboot your computer, make sure that the drives are plugged in, and then launch bash

-Reinstall Ubuntu by running lxrun/uninstall/full/y and then lxrun/install/y in cmd

-If nothing works, you can try making a symlink from the mount point of the usb drive to some folder on your C drive. I believe this article explains how to make them in Windows.

If none of this works, I would recommend reporting this as a bug to Microsoft. WSL is still under heavy development, and not nearly all of the features are working properly.

3

Consider a slight alternative on the currently top voted answer:

sudo mkdir /mnt/<usb_drive_letter>
sudo mount -t drvfs <usb_drive_letter>: /mnt/<usb_drive_Letter> -o uid=$(id -u $USER),gid=$(id -g $USER),metadata

For a USB drive which is assigned in Windows to H:, for example:

sudo mkdir /mnt/h
sudo mount -t drvfs h: /mnt/h -o uid=$(id -u $USER),gid=$(id -g $USER),metadata

In general, the other method will work, but note that drives that are manually mounted this way do not follow the normal WSL automount settings.

Most fixed Windows drives will be mounted:

  • In /mnt/<drive_letter for each drive.
  • With the default WSL user and its primary group as the owner of the mount.
  • A default umask/fmask/dmask of 000
  • The metadata disabled for performance, which means only a "simplified permission" model will be used to map Windows/NTFS and Linux permissions.

However, USB drives that are manually mounted do not follow the [automount] settings.

At the very least, you'll probably want your WSL user to be the owner, which is done with the -o uid=$(id -u $USER),gid=$(id -g $USER) (usually, this is the same as -o uid=1000,gid=1000 in a default Ubuntu/WSL installation).

Adding in the metadata option can be useful if you want to preserve permissions via rsync or cp -a.

2
  • Nice post nerd. +1. I use WSL every day and didn't know this. Makes sense.. follows unix mount. Commented Aug 9, 2022 at 21:44
  • @SeñorCMasMas Lol - And thanks! Same here -- I just happened to notice it when answering an Ask Ubuntu question earlier today. I thought for sure that manually mounted drvfs drives would use the [automount] settings, although in retrospect that seems counterintuitive. Commented Aug 9, 2022 at 21:46
0

Very late to this party but here's the official issue: https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13355724-unable-to-access-usb-devices-from-bash

In short, it's on their radar but it's not implemented yet. :(

1
  • The question is about local drives. Commented Mar 30, 2019 at 11:13
-4

Try this only If you are using WSL Linux (downloaded from Microsoft Store)

1.cd /mnt 2.cd D/

First part is something like start mounting and then you can simply add any drives.

1
  • 2
    All this does is change the current directory, it does not actually mount anything
    – MMM
    Commented Jun 1, 2021 at 7:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .