loading...

Mounting Network Drives into Windows Subsystem Linux

rpalo profile image Ryan Palo ・2 min read

This was initiated by my last article where I was counting directories on the command line.

At the end of the article, I wanted to show how it was done on the Linux CLI too, but I quickly ran into the problem that our server wasn't mounted into the Windows Subsystem Linux (WSL) file system. As it turns out, it's easier than I initially thought it would be!

Microsoft uses a new type of file system called DrvFs behind the scenes to allow the Linux subsystem to talk to native Windows directories. So you end up mounting a network drive just like you would mount any other media normally.

Let's say you've got a server on your network usually accessible as \\stroopwafel. To mount it into your WSL, you can do the following (I'm using Ubuntu, but it should be similar for the other distros):

sudo mkdir /mnt/stroopwafel
sudo mount -t drvfs '\\stroopwafel' /mnt/stroopwafel

Note: I used single quotes to avoid awkwardness around the backslashes in the network drive name.

If you have mapped the network drive to a drive letter on your Windows system already--let's say \\stroopwafel is mapped to S:\--or if you've just got a removable drive that isn't mounted yet but has a letter on your Windows system, the syntax changes a little:

sudo mkdir /mnt/stroopwafel
sudo mount -t drvfs S: /mnt/stroopwafel

If you ever want to unmount it:

sudo umount /mnt/stroopwafel

Posted on by:

rpalo profile

Ryan Palo

@rpalo

Ryan is an engineer in the Sacramento Area with a focus in Python, Ruby, and Rust. Bash/Python Exercism mentor. Coding, physics, calculus, music, woodworking. Message me on DEV!

Discussion

markdown guide