Skip to content

Add support for distro root filesystem other than ext4 #9339

Open

Description

I know ext4 is the well-supported standard, but other filesystems have so many additional features and better performance in several use cases.

From what I understand from the logs, ext4 filesystem type is somewhat hardcoded in WSL, here is what happens when I try to run a distro registered in-place with a btrfs filesystem on the VHDX:

[   61.888919] EXT4-fs (sdc): VFS: Can't find ext4 filesystem
[   61.889230] WSL (1) ERROR: Mount:1771: mount(/dev/sdc, /distro, ext4, 0x0, discard,errors=remount-ro,data=ordered
[   61.889233] ) failed 22
[   61.889856] WSL (1) ERROR: Invalid argument @main.cpp:2881 (ProcessMessage)

Describe the solution you'd like
The ideal world is something like WSL detects (or tells the kernel to detect) the filesystem present in the distro vhd.
Another solution could be to specify it but I don't see where you could specify such a per-distro setting outside the vhd itself (maybe in the registry?)

Describe alternatives you've considered
As btrfs is already supported in the original WSL2 kernel, I can mount an external btrfs vhd with wsl --mount, then chroot or something like that, but it's very inconvenient to do every time.

Additional context
I don't think this is the correct place to list the benefits of using other filesystems as distro's root, but my primary objective now is to use btrfs for its better performance, ability to enable compression and to take (and send/receive) snapshots.

Activity

  1. NotTheDr01ds commented on Dec 20, 2022

    @NotTheDr01ds

    I'm all in favor of this, but I do have a curiosity question since you seem to have already tried it out. How is btrfs performance under WSL2? Any benchmarks?

    I'd like to see it just for the snapshot capability, but it would be interesting to know what the performance delta is compared to WSL2's ext4.

  2. i2 commented on Dec 26, 2022

    @i2

    A semi-related news related to WSL performance which might interest you is that new patches are released to boost Linux 9p performance about 10 times!

  3. NotTheDr01ds commented on Dec 26, 2022

    @NotTheDr01ds

    i2 Yes, that would certainly be interesting. Where are those patches?! ;-)

  4. i2 commented on Dec 28, 2022

    @i2
  5. ahupp commented on Aug 6, 2023

    @ahupp

    I've love to see this as well. Right now I have some hacky startup scripts to mount a vhdx disk image and then mount that onto /home, but my setup would be simpler if the whole root filesystem could be btrfs.

  6. jtherin commented on May 13, 2024

    @jtherin

    +1 I would like XFS or BTRFS for wsl root filesystem

  7. theoparis commented on May 20, 2025

    @theoparis

    I've been looking to this now that WSL has been open sourced. The relevant lines seem to be here and here.
    However, I'm not sure what the best way of configuring this would be. Maybe a file system option in /etc/wsl.conf?

  8. Alireza-ft commented on May 20, 2025

    @Alireza-ft
  9. EdoaLive commented on May 27, 2025

    @EdoaLive
    Author

    I'm not sure what the best way of configuring this would be

    Theo Paris (@theoparis) I think the best would be to leave it to "auto" at mount time, this means that ext4 specific mount options should be added only if it's really an ext4 I think.
    Moreover /etc/wsl.conf would not be accessible when the filesystem is not yet mounted, and this config should be on a distro basis. Maybe in the registry?
    During creation I don't know but a command line flag could do the work

  10. artiga033 commented on Jun 10, 2025

    @artiga033

    I think the best would be to leave it to "auto" at mount time, this means that ext4 specific mount options should be added only if it's really an ext4 I think.

    I don't actually know how the 'auto' detection of fs type works and if it's really precise(or if it does, why MS hardcoded the ext4 stuff?) Moreover, say when using btrfs, I may want to configure different mount options, which is common( e.g. subvol and compress). So personally I insist that we need support user config.

    Maybe in the registry?
    During creation I don't know but a command line flag could do the work

    take a look at how they manage the default user
    \microsoft\WSL\src\windows\common\WslClient.cpp, though i did not find the function implmentation, but it seems finally to be stored in registry at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss with a subdir named by the guid of the distro.

    Image

  11. msuadOf commented on Oct 28, 2025

    @msuadOf

    Is there any news? Im focus on 'mount / on btrfs' recently, and think btrfs is really better than ext4 in many fields(eg. size,snapshot...).

  12. artiga033 commented on Oct 28, 2025

    @artiga033
  13. artiga033 commented on Jan 20, 2026

    @artiga033

    Good news guys, I have managed to do it! Successfully installed and booted into archlinux with / mounted as btrfs. You can even see how the transparent compression saves my space.

    Image

    I'm re-organizing the code and planning to make a release under my fork in several days.

    But still as I have explained above, submitting and convincing Microsoft to accept the change might still be non-trivial. This includes changes to the WSL core code, the COM interface definition and the WSLg systemDistro.

  14. artiga033 commented on Jan 22, 2026

    @artiga033

    If you wish to give it a try, check my fork release here. See the release notes for detail.

    I have been playing it for several hours and everything seems fine. However, I still insist you to think twice before really using it for your daily work.(For me, I have no choice because my Windows on ARM device even does not support mounting an non-root partition as an workaround, without the Windows insider channel, LOL.)

    I will consider submitting a PR once I further improve the codebase (e.g., adding more CLI control options, unit tests, etc.). However, I am not a professional C++ player, so it may take a long time and be quite challenging. Any help is welcome!

  15. nunix commented on Feb 26, 2026

    @nunix

    artiga033 great work, and went copied/copilot-ed your work into pre-release:

    Image Image

    Great work, and I'll be testing it with some Cloud Native distros in mind and Immutable distros too.
    And while I have the wsl.msi on one end, and the custom system distro on the other, somehow I cannot find the way to bundle them together as you did for your msixbundle. If you have these final step somewhere, can you share it?

    Really great work, a massive thank you 😄

  16. artiga033 commented on Feb 26, 2026

    @artiga033

    Nuno do Carmo (@nunix) To build it locally you will need to change the nuget config to point to your local build of WSLg, or it will always fetch online from Microsoft release.

    diff --git a/nuget.config b/nuget.config
    index 3fb4a71..3bec21c 100644
    --- a/nuget.config
    +++ b/nuget.config
    @@ -19,6 +19,7 @@
         <packageSources>
             <clear />
             <add key="WSL" value="https://pkgs.dev.azure.com/shine-oss/wsl/_packaging/WslDependencies/nuget/v3/index.json" />
    +        <add key="MyLocalSource" value="Y:\tmp\LocalNuget" />
         </packageSources>
         <disabledPackageSources>
             <!-- Override any User and Computer NuGet package settings to guarantee
    diff --git a/packages.config b/packages.config
    index e754b60..6016936 100644
    --- a/packages.config
    +++ b/packages.config
    @@ -22,7 +22,7 @@
       <package id="Microsoft.WSL.Kernel" version="6.6.114.1-1" targetFramework="native" />
       <package id="Microsoft.WSL.LinuxSdk" version="1.20.0" targetFramework="native" />
       <package id="Microsoft.WSL.TestDistro" version="2.5.7-47" />
    -  <package id="Microsoft.WSLg" version="1.0.73" />
    +  <package id="Microsoft.WSLg" version="1.0.73-artiga.2" />
       <package id="Microsoft.Xaml.Behaviors.WinUI.Managed" version="3.0.0" />
       <package id="StrawberryPerl" version="5.32.1.1" />
       <package id="vswhere" version="3.1.7" />
    

    In my case, I have a file at Y:\tmp\LocalNuget\Microsoft.WSLg.1.0.66-artiga.2.nupkg.

    As for the nuget file, I made it in a tricky way. Just download the official release from https://pkgs.dev.azure.com/shine-oss/wsl/_packaging/WslDependencies/nuget/v3/flat2/microsoft.wslg/1.0.73/microsoft.wslg.1.0.73.nupkg(change the version number as you need), unzip it(nuget packages are just zip archives), then replace the system.vhd files, and finally build it into a nuget package again via nuget cli.

  17. nunix commented on Feb 26, 2026

    @nunix

    perfect, thanks a lot, will try it. As said, the combined pieces work already, just wanted the 1 file integration.
    Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions