Sunday, 8 September 2019

Accessing removable media in Bash on Windows


Is there a way to access removable media (e.g. thumb drives or SD cards) from within Bash on Windows?


Bash on Windows uses DriveFs to mount fixed drives in the /mnt folder, but it doesn't automatically mount removable media. And it doesn't look like it puts them in /dev either:


Aaron@MYPC:/$ ls /dev
block fd kmsg lxss null ptmx pts random shm stderr stdin stdout tty tty0 tty1 urandom zero

Is there a way to mount removable drives? Is there a way to access the underlying block device?



Answer



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/


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...