Any attempt to open LINUX files using Windows tools may read-lock the opened files/folders, thereby stopping updates for your file contents. It invariably can result in files and folders becoming corrupted. Windows experts advise its customers to exercise extreme caution while attempting to create Linux files using Windows apps, tools, scripts, and consoles.
Creating or changing Linux files from Windows
If we dig a bit deeper into this subject and find why this phenomenon occurs in the first place, we’ll have our questions answered. Every Operating System has its file metadata, which differs from one OS to another. As a result, Windows file metadata is different from Linux file metadata and not recognized by Windows.
As a natural consequence, any effort to add or update Linux file metadata using Windows files would impose an unnecessary overhead on most Windows users who will not run WSL.
If you are not aware, WSL or Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables natively on Windows 11/10. So, It’s the sole responsibility of WSL to write/update Linux file metadata for all the files under your Linux filesystem root (i.e.,/), storing the Linux metadata in each file’s NTFS extended attributes. In addition to the above, WSL also synthesizes pseudo metadata for most of the files in your Windows filesystem.
The problem occurs when a user uses a Windows app/tool to open, create, or modify a file under your distro root (Linux filesystem containing Linux files or any of the files and folders under %localappdata%\lxss). Since Windows application/program was used to create the file, it won’t have any Linux file metadata (e.g., permissions, owner, access/update timestamps, etc.). Therefore, for a Linux system configured only to receive Linux file metadata, the file may have some metadata but will appear as empty, corrupting contents in the file.
To avoid such instances of misfortune, follow these two rules to avoid losing files or corrupting your data,
- First, never try to store files in your Windows filesystem you want to modify using Windows tools AND Linux tools.
- Second, DO NOT attempt to create/modify Linux files from Windows apps, tools, scripts, or consoles.
Updates for WSL in Windows
- In May 2019, Microsoft released Windows 10 version 1903, which introduced a new feature that allows Windows applications and tools to access Linux filesystems directly, bringing a significant enhancement to the WSL. This capability was facilitated by a 9P protocol fileserver hosted by WSL, which exposed the Linux distro’s filesystem through a network path.
- With its launch in Windows 10 version 2004, WSL 2 introduced a complete overhaul with a real Linux kernel running inside a lightweight utility virtual machine (VM).
- In 2021, Microsoft introduced WSLg (Windows Subsystem for Linux GUI), which allowed users to run Linux GUI applications directly on Windows without needing a third-party X server.
These updates have continued to bridge the gap between Windows and Linux, making it convenient for developers and power users to leverage the strengths of both operating systems on a single machine.
For more information, visit MSDN Blog.
Does Windows support Linux?
You can use WSL or Windows Subsystem for Linux to install any of the Linux Distro and then access Windows files as well. The Windows Subsystem for Linux lets developers run a GNU/Linux environment — including most command-line tools, utilities, and almost everything Linux can run.
Is WSL better than VM?
VMs are an excellent choice if you plan to use them in isolated or networked environments. The WSL command-line tool allows you to use Linux commands on your Windows system (to modify Windows files) easily.
How is Linux file system different from Windows file system?
The Linux and the Windows filesystems are fundamentally different from each other in terms of design, architecture, and the way they handle data and file organization. While the Linux filesystem is designed for flexibility, performance, and robust permission handling, the Windows filesystem, especially NTFS, focuses on user-friendliness, security features, and compatibility with a broad range of applications.
Can a Linux subsystem access Windows files?
Yes, a Linux subsystem can access Windows files through an automatic mounting system while running within the Windows Subsystem for Linux (WSL). In WSL, the Windows file system is automatically mounted under the /mnt directory within the Linux environment, with each drive appearing as a subdirectory (e.g., /mnt/c for the C: drive). Once the Windows drives are mounted, you can use standard Linux commands and tools to navigate, manipulate, and process these files.
Read Next: How to install Windows Subsystem for Linux on Windows.