Open Source

Windows 10 update arrives, improves support for Linux subsystem

0

Update: I just installed Windows 10 insider build update 19h1_release that brings the much requested feature that allows users to access Linux filesystem using Explorer.

WLS or Windows Subsystem for Linux is the best thing that ever happened to developers and sysadmins who used both Linux and Microsoft ecosystems to develop, deploy and manage their workloads running on remote Windows and Linux machines.

[Note: Support our Linux & Open Source coverage by becoming a Patron!]

As some who keeps an eye on all three platforms – Linux, macOS and Windows; I have been playing with WSL from the day one.

The project has come a long way. It’s so impressive that now I can not only manage my servers & containers from Windows, I can also use many useful Linux utilities like ‘rsync’ without spinning a virtual machine or resorting to workaround.

However, it’s still a work in progress. I would very much want to easily ‘ssh’ into my Windows machine and manage files via command line, as I can do on macOS and Linux. I wish I could gain native access to Linux filesystems from within Windows, without risking the distro. I wish…

I am not alone who has way too many expectations from WSL. The good news is Microsoft is actively working on improving WSL experience. Soon users will be able to ‘safely’ access Linux filesystems using native Windows apps like File Explorer.

‘Safely’ because you can already access the Linux file system from within Windows apps and tools, but doing so will corrupt the Linux distribution. Why? Linux and Windows are two alien worlds. “Windows file metadata is different from Linux file metadata,” explained Rich Turner, Sr. Project Manager at Microsoft.

So when you access, edit or create files in your Linux distro’s filesystem from Windows, it will change the metadata (e.g., permissions, owner, access/update timestamps, etc.) of those files. It will result in a broken system.

The ability to access and edit Linux filesystems has been one of the top requests of users. As expected, Microsoft found a clever way to solve the issue.

Microsoft is using 9P protocol file server to act as a bridge between Windows and Linux Subsystem. 9P is a network protocol similar to Samba which was designed for Bell Labs’ Plan 9 distributed system to connect the components of the OS with each other. This server contains protocols that support Linux metadata, including permissions, which solves the problem that Windows faced with accessing Linux filesystems.

“This server contains protocols that support Linux metadata, including permissions. There is a Windows service and driver that acts as the client and talks to the 9P server (which is running inside of a WSL instance). Client and server communicate over AF_UNIX sockets since WSL allows interop between a Windows application and a Linux application using AF_UNIX,” explained Craig Loewen, a Program Manager at Microsoft.

As soon as you install 1903 version of Windows on your machine, you will get the brand new WSL which will bring this feature to your machine.

Access any file within the Linux filesystem using Explorer.

To be able to access files within the Linux file systems, just change directory into the home directory of the Linux distro and then run the explorer.exe command which will open the director in Explorer window, go ahead and do what you want.

Some caveats
It’s a new feature and functionality. It’s work in progress so there are some wrinkles to be ironed out. At the moment, you need to run your distribution if you want to access its file systems. The reason is simple, P9 server needs to be running in order to access the file system, which means you need to run the distro. The good news is that WSL teams are working on a solution.

The second limitation is that since it’s using a network protocol to access Linux filesystems, the restrictions of what you can and can’t with that network protocol also applies. You can use CMD (command prompt on Windows) to change directory into “\wsl$\Ubuntu\home” because CMD does not support UNC (Universal Naming Convention) paths as current directories. But you can copy files such as “\wsl$\Ubuntu\home\somefile.txt C:\dev\”

The third limitation is that you still can’t access Linux files inside of the AppData folder. Loewen Wans that “if you try to access your Linux files through your AppData folder, you are bypassing using the 9P server, which means that you will not have access to your Linux files, and you could corrupt your Linux distro.”

New Features
These limitations aside, the new version of WSL brings many other features including new commands:
–user, -u
Run as the specified user
–export
Exports the distribution to a tar file.
The filename can be – for standard output.
–import
Imports the specified tar file as a new distribution.
The filename can be – for standard input.
–terminate, -t
Terminates the distribution.

Some other useful commands are:
–list , -l
Lists all distributions available on your machine
Can also contain further options:
–all
Lists all distributions, including distributions that are currently being installed or uninstalled
–running
Lists only distributions that are currently running
–setdefault, -s
Sets the distribution as default.
–unregister
Unregisters the distribution
–upgrade
Upgrades the distribution to the WslFs file system format.

I am running updates on my Windows machine and will report back on how has been my experience so far.