Saturday, April 1, 2017

Handling Linux Files In Windows

      Microsoft says - “Don’t change Linux Files in Windows”
In it’s anniversary update, Microsoft had introduced Linux Subsystem, WSL, for Windows. Which allowed developers to use Bash on Ubuntu on Windows 10.
In a new blog post, Microsoft has mentioned some of the limitations while using Windows tools for changing Linux files. 

Microsoft’s advisory states that t he Windows 10 users MUST NOT change Linux files using Windows apps, tools, consoles, scripts, etc. “under any circumstances”. From “Linux Files”, Microsoft means content under %localappdata%lxssâ€"which is where Linux filesystem is stored.

Doing this may result in data corruption or (and) damage to the Linux Environment in Windows 10. Solution of which remains â€" reinstallation of their Linux Distro.

Now the question arises : Why is Microsoft stopping users from changing Linux Files?

The file metadata representation is different in Linux as compared to Windows 10. As Linux subsystem files are stored in an NTFS folder in Windows 10, WSL calculates and stores Linux metadata in NTFS extended attributes. But, Windows apps and tools don’t know how to deal with this metadata each time they change files stored in %localappdata%lxss.
Image Source - Microsoft
So, basically if one will use some app/console/tool to create or change any file, it won’t be having any metadata. As a result, WSL will assume that the file is corrupted and it won’t work properly.
Microsoft thus has advised the developers to access the Linux subsystem files from within Bash. “WSL honors the NT filesystem behaviors (e.g. case-insensitivity), permissions, etc. so you can easily access the same files using both Windows tools and Bash tools without having to copy files back and forth between filesystems,” Microsoft mentioned in the blog post. 

What now?
The solution is pretty clear and simple, if you have to work on the files using both Windows and Linux, “store & work on those files in your Windows filesystem, and ac cess them from both Windows and from Bash via /mnt/<drive>/path (e.g. /mnt/c/dev/project/...)”. 

Microsoft, in it’s blog post added the following caution points to sum everything:

1. Do store files in your Windows filesystem that you want to create/modify using Windows tools AND Linux tools

2. Do not create / modify Linux files from Windows apps, tools, scripts or consoles.

So, when you get your hands on Windows 10, and start enjoying it’s features of Anniversary Update, make sure you don’t end up experimenting too much. For more information, refer to Microsoft’s blog post on the same : 
https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/
The team of Geek Winky will keep coming with the updates required, when you get your hands on the newest updates from the company giants! Stay in touch for more...

Article By : Kushash wa Ravi Shrimali
Ping me up at : kushashwa@geekwinky.in

No comments:

Post a Comment