Windows Subsystem for Linux doesn’t automatically mount removable drives, which has long been a source of frustration for me. I want to leave a note to myself with my findings. If this helps anyone else, even better!
There are two approaches I’ve used:
Using a bash script is a straightforward way to mount drives. My script is very simple, first checking if the directory I’m going to use with the mount exists, and if not, create it, and then mount the drive (I’m a bash newb, so please feel free to suggest improvements):
#!/bin/bash readonly DPath='/mnt/d' if [ -d $DPath ]; then echo "$DPath already exists" else sudo mkdir /mnt/d fi sudo mount -t drvfs D:\ /mnt/d
I recently stumbled upon this option, in which WSL processes /etc/fstab at instance start. This is basically set it and forget it. Here’s what I added to my /etc/fstab:
D:\ /mnt/d drvfs