How to Access Linux Ext4 Partitions in Windows Using WSL

If you’re a Linux user who also works with Windows, or just curious about exploring Linux files from a Windows environment, you might have come across a challenge: accessing Linux's Ext4 partitions from within Windows. Thanks to advancements in Windows Subsystem for Linux (WSL), you can now easily access these partitions directly from Windows without the need for third-party software. In this guide, we’ll walk you through the process step by step, explaining everything you need to know.

 What is WSL?

Before we dive into the instructions, let’s briefly talk about WSL. Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables natively on Windows. Essentially, it allows you to run a Linux distribution, like Ubuntu or Debian, within your Windows environment without the need for a virtual machine or dual-boot setup.

WSL 2, the latest version, introduced a full Linux kernel running in a lightweight virtual machine, which provides improved performance and more extensive system call compatibility. Among its many benefits, WSL 2 can now access Linux filesystems, including Ext4, directly from Windows.

 Why Access Ext4 Partitions?

Ext4 is a popular file system used by Linux distributions. However, Windows doesn’t natively support Ext4, which can make it difficult to access files on a Linux partition from a Windows environment. This can be problematic if you’re dual-booting Linux and Windows or if you have external drives formatted with Ext4.

By using WSL, you can access these partitions directly, making it easier to work across both operating systems without switching between them.

 Prerequisites

Before you begin, ensure you have the following:

1. Windows 10 Version 20211 or Later: The ability to access Linux filesystems directly from Windows is available in Windows 10 build 20211 and later. You can check your Windows version by typing `winver` in the Run dialog (Win + R).

2. WSL 2 Installed and Configured: Ensure that WSL is installed on your machine and configured to use WSL 2. If you haven’t set this up yet, follow these steps:

    - Open PowerShell as Administrator and run the following command to enable WSL:

      ```shell

      wsl --install

      ```

    - To upgrade to WSL 2, run:

      ```shell

      wsl --set-default-version 2

      ```

3. A Linux Distribution Installed via WSL: You need to have at least one Linux distribution installed from the Microsoft Store. Ubuntu is a common choice, but you can pick any available distribution.

 Step-by-Step Guide to Access Ext4 Partitions

 Step 1: Open WSL and List Available Disks

1. Launch a WSL terminal by searching for your installed Linux distribution (e.g., Ubuntu) in the Start menu and opening it.

2. Inside the WSL terminal, list all available disks by running:

   ```shell

   wsl --mount

   ```

   This command will show a list of all disks and partitions that WSL can access. Look for the partition labeled as Ext4.

 Step 2: Mount the Ext4 Partition

To mount the Ext4 partition, use the following command:

   ```shell

   wsl --mount <DiskName> --partition <PartitionNumber> --type ext4

   ```

   Replace `<DiskName>` with the name of the disk and `<PartitionNumber>` with the partition number you want to mount. For example:

   ```shell

   wsl --mount \\.\PHYSICALDRIVE0 --partition 1 --type ext4

   ```

   This command mounts the Ext4 partition to a directory within your WSL environment, typically under `/mnt`.

 Step 3: Access Your Files

Once the partition is mounted, you can access it from within the WSL terminal. Navigate to the mount point using:

   ```shell

   cd /mnt

   ```

   You’ll see your Ext4 partition mounted here, and you can navigate through your Linux files just like you would on a native Linux system.

 Step 4: Access Files from Windows Explorer

WSL also makes it easy to access your Linux files directly from Windows Explorer. In your WSL terminal, you can open the mounted directory in Windows Explorer by running:

   ```shell

   explorer.exe .

   ```

   This command opens the current directory in Windows Explorer, allowing you to drag and drop files between your Linux partition and Windows.

 Unmounting the Partition

When you’re done accessing your Linux files, it’s a good idea to unmount the partition. You can do this with the following command:

   ```shell

   wsl --unmount <DiskName>

   ```

   Replace `<DiskName>` with the name of the disk you mounted earlier.

 Troubleshooting Tips

- Missing Mount Points: If you can’t see your Linux partitions, double-check the disk and partition numbers using the `wsl --mount` command.

- Permission Issues: If you encounter permission issues, ensure you’re running WSL with the necessary administrative privileges.

- Updating WSL: If you’re running an older version of Windows 10, consider updating to the latest version to ensure compatibility.

 Conclusion

Thanks to WSL 2, accessing Ext4 partitions from Windows has become straightforward and efficient. Whether you’re a developer working across systems or a casual user, this feature bridges the gap between Linux and Windows, making it easier to manage and access your files without rebooting or relying on third-party tools. 

With the steps outlined above, you should be able to access and work with your Linux files directly from your Windows environment with ease.