Losing Read Attribute on Files Uploaded on Ubuntu 14.04
Exercise not change Linux files using Windows apps and tools
Update – May 2019 Windows 10 version 1903 has now been released and allows an important update to WSL that allows Windows applications and tools to access Linux files straight. To do this, WSL hosts a new 9P fileserver, which exposes distro filesystems to Windows apps and tools via
\\wsl$\<DistroName>\! You can read all about the feature in the blog mail service "What's new for WSL in Windows 10 version 1903".The postal service below contains the original guidance, which also remains true: DO Non access the Linux files inside of your
%LOCALAPPDATA%binder, since you should only exist accessing them . If you'd like to acquire more than about why you lot shouldn't become excavation through the Appdata binder for your Linux files, delight read on!
There is one hard-and-fast rule when it comes to WSL on Windows:
Do Not, under Any circumstances, admission, create, and/or change Linux files inside of your `%LOCALAPPDATA%` binder using Windows apps, tools, scripts, consoles, etc.
Opening > files using some Windows tools may read-lock the opened files > and/or folders, preventing updates to file contents and/or metadata, > essentially resulting in corrupted files/folders.
Creating/changing Linux files in your Appdata folder from Windows will likely result in data corruption and/or harm your Linux environment requiring you to uninstall & reinstall your distro!
Note: In beta versions of WSL, your "Linux files" are any of the files and folders under %localappdata%\lxss – which is where the Linux filesystem – distro and your own files – are stored on your drive. In supported versions of WSL, the filesystems for the distros you install via the Microsoft Store are stored elsewhere on disk … for good reason!
What SHOULD I do?
To work on files using both Windows and Linux tools, store files in your Windows filesystem – this will enable you to access the same files from both Windows and from your Linux distros via /mnt/<drive>/<path> (e.g. /mnt/c/dev/project/...),
When you access files on your Windows filesystem from within Bash, WSL honors the NT filesystem behaviors (e.m. case-insensitivity), permissions, etc. so y'all can easily access the same files using both Windows tools and Bash tools without having to copy files back and forth between filesystems.
Therefore, exist sure to follow these iii rules in order to avert losing files, and/or corrupting your data:
- DO store files in your Windows filesystem that you lot want to access/create/modify using Windows tools AND Linux tools
- DO access / create / change files in your Linux distros' filesystems from Windows apps, tools, scripts or consoles using
\\wsl$\<DistroName>\ -
DO NOT access / create / change files in your Linux distros' filesystems from Windows apps, tools, scripts or consoles past finding the files in Appdata
Call up: There'southward a reason nosotros store your distros' filesystems in non-obvious locations!
Why is this?
File metadata (e.thou. permissions, ownership, timestamps, etc.) is stored for every file, binder, etc., on your storage devices. Alas, file metadata representation differs from one Bone to another: Windows file metadata is dissimilar from Linux file metadata.
While it'due south the OS' job to store and update your file metadata, almost of Windows doesn't know annihilation virtually Linux, nor Linux file metadata, and doesn't automatically add together or update Linux file metadata for all Windows files because that would impose an unnecessary overhead on the vast majority of Windows users who will never run WSL.
It'southward WSL's job to write/update Linux file metadata for all the files nether your Linux filesystem root (i.e. /), storing the Linux metadata in each file's NTFS extended attributes. WSL too synthesizes pseudo metadata for almost of the files in your Windows filesystem.
The problem arises when, for instance, you lot employ a Windows app/tool to open, create and/or alter a file under your distro root: Since the file was created with a Windows tool, the file won't have whatever Linux file metadata (eastward.g. permissions, possessor, access/update timestamps, etc.). Thus, to Linux, (which only receives Linux file metadata), the file may be reported as empty, may non even be, or may have some metadata, simply that metadata may not reflect the file'southward details resulted in the file's contents being corrupted.
Further, equally in Linux, some Windows tools implement unusual filesystem access patterns to handle file updating and don't actually edit files in-identify: When apps/tools save changes to a file, the original files are often deleted and re-created, etc. During such operations, NT file "extended backdrop" (i.e. Linux file permissions) are oft non copied and are "lost".
For more background into how the WSL filesystem infrastructure works, be certain to read/lookout this AWESOME web log & video which explains things in much more than detail.
Please help u.s.a. share this guidance far and wide – tweet, mail and blog, linking back to this post!!
Thank you.
Update Log:
- [2017-03-14] – Updated "Why is this"; thanks to @mn in comments
- [2019-01-15] – Minor updates & improvements
- Last Updated: [2019-05-29] – Added an edit to the top of the post to describe the new characteristic allowing users to access Linux files from Windows
Source: https://devblogs.microsoft.com/commandline/do-not-change-linux-files-using-windows-apps-and-tools/
0 Response to "Losing Read Attribute on Files Uploaded on Ubuntu 14.04"
Post a Comment