When you finish installing WSL and open the terminal for the first time, you’ll probably be wondering how to access the files on your C: drive or other hard drives, flash drives, etc.
WSL will mount your hard drives for you automatically under the
/mnt directory. The C: drive can always be accessed there, and usually other fixed NTFS drives that you have installed will be mounted there as well. But if you don’t see them, they are easy to mount.
Accessing the C: drive
Your main hard drive should always be accessible under /mnt/c
A simple change directory command should take you to the root of your C: drive…
Accessing other drives and removable media
If you have a second hard drive or removable media such as a flash drive, you can try accessing them through the /mnt directory as well, obviously by appending the appropriate drive letter to /mnt/
If you can’t access your drives/media that way, you’ll just need to mount them first, which Windows has made very simple in WSL. In this example, we’ll mount and access drive D: in Ubuntu on Windows Subsystem for Linux.
sudo mkdir /mnt/d sudo mount -t drvfs D: /mnt/d
cd /mnt/d && ls
You can mount your media anywhere you’d like; the thing to note here is that you must use Microsoft’s DrvFS when mounting accessible media within the subsystem.
In the case of removable media, you unmount them in the traditional way for safe removal:
sudo umount /mnt/d
Adding drives to fstab
To automatically mount drives, edit the
/etc/fstab file and add a line:
D: /mnt/d drvfs defaults 0 0
Of course, change D: to any hard drive letter you need, as well as the mount point.