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

Craig Loewen

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.

12 comments

Discussion is closed. Login to edit/delete existing comments.

  • Yiannis Charalambous 0

    Is WSL 2 going to get X server support?

    • Michel Firholz 0

      I installed XRDP and could run an XFCE desktop from the remote desktop connection.
      Maybe that helps.

  • yahya elfazazi 0

    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?

  • Aleksey M 0

    “…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?

    • Jester, Jake (NIH/NIAID) [C] 0

      Same. Please don’t mess up native file editing, symlink or no symlink.

  • Jim Fehrle 0

    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.)

    • Craig LoewenMicrosoft employee 0

      In general, the virtual hard disk will resize to meet your storage needs. More details will follow as we release WSL 2!

  • Ian Yates 0

    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! 

Feedback usabilla icon