You can access all your Windows PC’s files in WSL by mounting hard drives, flash drives, and other removable disks. In this guide, we’ll see how to mount our file systems in Windows Subsystem for Linux in order to access our files, as well as how to automate the process.
Accessing C: Drive
WSL will ordinarily mount your hard disks for you automatically in the
/mnt directory. You can access the C: drive from under
$ cd /mnt/c
Accessing secondary drives and removable media
To access other drives and removable media like flash drives, you can try the
/mnt directory. So for your D: drive, you’d navigate to it in terminal with the following command.
$ cd /mnt/d
However, this doesn’t always work, as WSL may not mount these other drives automatically. In that case, we can mount them with the
mount command. Run the following commands with sudo or the root user account. Remember to replace
D: with whichever drive letter you’re trying to mount.
$ sudo mkdir /mnt/d $ sudo mount -t drvfs D: /mnt/d
Of course, you don’t you have to use the
/mnt directory. You can mount the drives wherever you like as long you use Microsoft’s DrvFs as the filesystem type in your
If you need to unmount a drive, you can use the normal
umount Linux command.
$ sudo umount /mnt/d
Mount Drives Automatically
Rather than having to run mount commands every time you open WSL, we can mount the drives automatically and persistently by making some edits to the system’s
/etc/fstab file. For example, adding the following line will automatically mount the D: drive.
D: /mnt/d drvfs defaults 0 0
It’s safe to ignore any default lines that are already in this file. Just make your changes to the bottom of the file.
Mounting in Read Only Mode
In case you’d like WSL to be able to read your files, but not make any changes to them, you can also mount a drive in read only mode by specifying the
-o ro option in your command.
$ sudo mount -o ro -t drvfs D: /mnt/d
That’s all there is to it. Now you know how to mount any drive or removable disk in WSL, either temporarily or persistently.