A Deep Dive Into How WSL Allows Windows to Access Linux Files

Craig Loewen

Craig

Three months ago, we announced that the Windows Subsystem for Linux will be able to access Linux files from Windows in the blog post: What’s new for WSL in Windows 10 version 1903, and in today’s post we will be showing you how we made these changes possible.

Let’s jump in!

We’re continuing our whiteboard series of deep dives (you can find the full list here) with a new video where Sven Groot and Craig Loewen explain the full architecture behind this new feature. You can expect to learn about how WSL currently accesses Linux files, how we’ve added a 9P file server into the init process of each Linux distro, and how Windows interacts with that 9P file server to interact with Linux files inside of your distro. So, grab a coffee and a snack, sit down, relax, and enjoy this look behind the scenes of WSL!

You can also view this video on Channel 9 and on YouTube.

How does this story fit in with WSL 2?

We don’t explicitly mention WSL 2 in the video above as at the time of filming we were still finalizing the details behind WSL 2, and ultimately there are very little changes to our explanation of how Linux files are accessed from Windows with the new architecture.

The only difference from the explanation in the video, is where the Linux files themselves are stored. In WSL 1, these Linux files are stored in the Windows drive (which uses the NT file system), while in WSL 2 these Linux files are stored in a virtual hard disk which uses the EXT4 file system. Every other detail on how the files are accessed remains the same.

What would you like to see next?

If you have more questions about how we use a 9P file server, accessing Linux files, or just about WSL in general you can find a list of our team members on twitter here! Please feel free to reach out to ask us any questions, and give suggestions on any other deep dives that you’d be interested in seeing.

Craig Loewen
Craig Loewen

Program Manager, Windows Developer Platform

Follow Craig   

10 Comments
Avatar
Yiannis Charalambous 2019-05-30 16:46:13
Is WSL 2 going to get X server support?
Avatar
yahya elfazazi 2019-05-30 18:07:48
After exporting my wsl distro from my desktop to laptop, and importing it , the default user is root i can't change it to my unix user, the command like : ubuntu config --default-user <user_name>.not work for me, any help please?
Avatar
Aleksey M 2019-05-31 02:42:54
"...in WSL 2 these Linux files are stored in a virtual hard disk which uses the EXT4 file system" In WSL1, I could make symlink from "/mnt/c/MyDir" to "/var/www/MyDir" and edit files as native in Windows and use folder "/var/www/MyDir" in Linux.Will I can make the same in WSL2?
Avatar
Jim Fehrle 2019-05-31 09:51:41
Does the virtual hard disk require reserving physical drive space in advance?   If so, you'd have separate pools of free disk space, one for Windows and one for Linux that are not shared.  Is it possible to increase the amount of space for the drive after installing Linux? (Didn't watch the video, too long.)
Avatar
Ian Yates 2019-06-03 04:35:59
Glad to see the extra clarification around WSL2. It makes sense it's in a separate virtual disk and I'm sure that'll help with the speed.  What I don't understand is how you plan on allowing seamless up and down grading of environments between WSL 1 & 2? That was implied in an earlier blog post.  Would it copy files to & from the VHDX? Or am I over thinking things and the up & down grading won't preserve any settings at all? (so more that you can choose a default for your PC but the two WSL Linux "worlds" are completely separate) Thanks for the posts! 
Avatar
Dean Jackson 2019-06-18 07:23:15
The "Load more" button at the bottom of this page will continually load the same comments that are already showing on the page.
Avatar
Leandro Arajo 2019-06-25 13:42:47
Let's say I have a full blown Linux partition in some physical disk in my rig. Is it possible to mount that extern linux partition and access content in WSL2? And what about the opposite? To use an linux instalation or pendrive linux to access the content in this virtual disk from WSL2?