The Windows Subsystem for Linux (WSL) uses different filesystems depending on the version (WSL1 or WSL2) and how it is configured. Here's a breakdown:
1. WSL1 (Windows Subsystem for Linux 1)
Underlying Filesystem: NTFS (the native Windows filesystem).
How It Works:
WSL1 does not use a full Linux kernel. Instead, it translates Linux system calls into Windows system calls using a compatibility layer.
The Linux filesystem is not isolated from Windows. It is essentially a virtualized Linux environment that shares the same Windows NTFS filesystem.
Files created or accessed in WSL1 are stored directly on the Windows NTFS drive (e.g., C:\).
For example, the Linux root filesystem (/) is mapped to a directory like C:\Users\<User>\AppData\Local\Microsoft\WindowsApps\ or similar.
Key Points:
No virtual machine (VM) is used.
Direct access to Windows files from WSL1 (e.g., /mnt/c maps to C:\).
Limited support for Linux-specific features (e.g., kernel modules, certain system calls).
2. WSL2 (Windows Subsystem for Linux 2)
Underlying Filesystem: NTFS (Windows) for storing the virtual disk (VHD), but the Linux filesystem inside the VM is ext4.
How It Works:
WSL2 uses a lightweight virtual machine (VM) with a full Linux kernel (based on Ubuntu).
The Linux root filesystem is stored in a VHD (Virtual Hard Disk) file, which is a single file on the Windows NTFS filesystem.
By default, the VHD is stored in a directory like C:\Users\<User>\AppData\Local\Microsoft\WSL\ (e.g., distribution_name-ext4.vhdx).
The Linux filesystem inside the VHD is typically ext4, which is standard for most Linux distributions.
Key Points:
Files in the Linux environment are stored in the VHD (ext4), while the VHD itself is stored on NTFS.
Windows files are accessible via /mnt/c, /mnt/d, etc., but these are mounted as read-only or read/write (depending on configuration).
Supports full Linux features (e.g., kernel modules, system calls, Docker).
3. Hybrid Approach (WSL1 vs. WSL2)
Filesystem Interaction:
WSL1: Directly uses NTFS for all files.
WSL2: Uses a virtualized Linux filesystem (ext4) inside a VHD, but the VHD is stored on NTFS.
Cross-Access: Files in WSL2 can access Windows files via /mnt/c, but modifications to Windows files from WSL2 may require special handling (e.g., chown or chmod).
Summary
Feature
WSL1
WSL2
Filesystem
NTFS (Windows)
ext4 (Linux) inside a VHD (NTFS)
Storage
Directly on NTFS
VHD file on NTFS
VM Usage
No VM
Yes (lightweight Hyper-V VM)
Linux Features
Limited
Full support
Windows File Access
Direct (via /mnt/c)
Mounted as /mnt/c (read/write)
Additional Notes
Default Filesystem for WSL2: The Linux filesystem inside WSL2 is typically ext4, but you can configure other filesystems (e.g., btrfs) if needed.
Performance: WSL2 generally offers better performance for Linux workloads due to its full kernel support, but it requires more system resources.
For most users, WSL2 is recommended for modern workflows, as it provides a more authentic Linux environment while leveraging Windows' file system for storage.