With the Windows Subsystem for Linux, we’ve always allowed you to treat your files as case sensitive, just like Linux does. In the past, if you had files whose name differed only by case, these files could not be accessed by Windows, because Windows applications treat the file system as case insensitive.
A while ago, we introduced per-directory case sensitivity. This allows specific directories to be treated as case sensitive by both WSL and Windows applications. Because Linux developers usually expect the file system to be case sensitive, we opted to make new directories created by WSL on your Windows volumes case sensitive by default.
Unfortunately, this had an unintended side effect. Some Windows applications, using the assumption that the file system is case insensitive, don’t use the correct case to refer to files. For example, it’s not uncommon for applications to transform filenames to use all upper or lower case. In directories marked as case sensitive, this means that these applications can no longer access the files.
While in the long term the preferred solution is to fix these applications to correctly handle case sensitive directories, we realize that this isn’t always an option, and you, our customers, shouldn’t have to wait for that.
Additionally, if Windows applications created new directories in a directory tree where you are using case sensitive files, these directories would not be case sensitive. This made it difficult to work with Windows tools in case sensitive directories.
For these reasons, we have made two changes to how case sensitive directories work: an extended attribute to control case sensitivity in WSL, and inheritance of the case sensitivity flag for new directories.
Using Linux extended attributes to get and set per-directory case sensitivity
As of Windows insider build 17692, it’s now possible to inspect and modify the case sensitivity flag for a directory from inside WSL. Case sensitivity is exposed using an extended attribute named system.wsl_case_sensitive
. The value of this attribute will be 0
for case insensitive directories, and 1
for case sensitive directories.
To manipulate extended attributes from the terminal, you can use the setfattr
and getfattr
applications. On Ubuntu, these can be installed using sudo apt install attr
.
With these applications, you can determine if a directory is case sensitive using:
getfattr -n system.wsl_case_sensitive <path>
Mark a directory as case sensitive:
setfattr -n system.wsl_case_sensitive -v 1 <path>
Mark a directory as case insensitive:
setfattr -n system.wsl_case_sensitive -v 0 <path>
The following shows an example where a case insensitive directory is marked as case sensitive:
Note: changing the case sensitivity attribute requires “Write attributes”, “Create files”, “Create folders” and “Delete subfolders and files” permissions on the directory. In some cases, with folders outside your user profile, you may not have all these permissions by default even if you own the directory. If you receive an access denied error when changing the attribute, make sure you have the correct Windows permissions on the folder.
Changing the case sensitivity attribute requires that none of the folder’s descendants are currently open in WSL. It is not possible to disable per-directory case sensitivity on a directory that contains files whose names only differ by case.
The case sensitivity attribute is not available on file systems that do not support per-directory case sensitivity, such as FAT or SMB file systems. Currently, only local NTFS volumes support per-directory case sensitivity.
Case sensitivity inheritance
Previously, it was necessary to explicitly mark every directory you create as case sensitive. Now, we’ve made it so that the per-directory case sensitivity flag is inherited when creating a new directory. This means that new directories created in a case sensitive directory are automatically case sensitive.
The big advantage of this is that it’s now much easier to use certain Windows tools in case sensitive directories. For example, you can use the in-box tar.exe to extract an archive in a case sensitive directory, and be sure the entire directory subtree is case sensitive. Similarly if you clone a repository using Git for Windows, or if you create new directories using an editor such as Visual Studio Code. This makes it much easier to use Windows applications with case sensitive directories, without needing to modify those applications.
Case sensitivity mount options in DrvFs
When mounting Windows volumes in WSL with DrvFs, you can specify the default case sensitivity behavior using the case=off
or case=dir
mount option. With case=off
, new directories are not case sensitive by default. With case=dir
, they are case sensitive by default. In either case, directories already marked as case sensitive will be treated as case sensitive.
These options are not new, but combined with the system.wsl_case_sensitive
extended attribute and case sensitivity inheritance, they give you greater control over where per-directory case sensitivity is used.
Now, if you mount DrvFs using case=off
, it is easy to mark directories case sensitive when you want them to be, and since inheritance also applies to WSL even with case=off
, you can be sure the entire subtree will be case sensitive.
The following example shows how a new directory created in a case sensitive directory is also case sensitive, even when using case=off
:
We recommend that you start mounting your DrvFs volumes using case=off
and only enable per-directory case sensitivity when you need it. This can be accomplished using the /etc/wsl.conf file. The following is an example wsl.conf file that sets case=off
as the default for automounted DrvFs volumes:
[automount] options = case=off
In a future Windows Insider build, we will change the default behavior for DrvFs to be case=off
if no options are specified, and you will need to explicitly mount with case=dir
if you want to use the old behavior.
Thanks and Feedback
A big thanks for helping provide feedback on case-sensitivity. Be sure to continue providing feedback on the WSL GitHub repo and Tweeting us at #WSLinux.
Permission denied ,how to resolve it ?
Sorry – we’re going to need more info and repro steps to help you. Please file an issue on the WSL or Terminal repos and provide the info requested in the issue template.