How to mount a Linux file system using WSL2 on Windows 10

How to mount a Linux file system using WSL2 on Windows 10

Starting with build 20211, Windows Subsystem for Linux 2 (WSL2) includes a new feature that allows you to attach and mount physical drives to access the Linux file system (such as ext4) which is not supported. support on Windows 10.

This new feature is intended to help you access Linux files using File Explorer on a dual boot system running Windows 10 and a Linux distribution on another drive.

In this tutorial, you will learn the steps to mount and unmount a drive using Windows Subsystem for Linux 2.

Mount Linux file system on Windows 10

To mount the Linux file system using WSL2, follow these steps:

1. Open Start on Windows 10.

2. Search for PowerShell , right-click on the top result and select the option Run as administrator .

3. Type the following command to list available physical drives and press Enter :

wmic diskdrive list brief

4. Confirm the drive path in the “Device ID” column .

5. Type the following command to mount the Linux file system and press Enter :

wsl --mount DISKPATH
Enter the command to mount the Linux file system

In this command, be sure to replace DISKPATH with the path of the drive where the Linux distribution you want to mount. For example:

wsl --mount .PHYSICALDRIVE2

If you want to mount a specific partition, you will need to use the –partition option with the partition number. For example:

wsl --mount .PHYSICALDRIVE2 --partition 1

After you complete the steps, the drive containing the Linux files will mount and will show up on Windows 10.

  • How to set Linux distro version to WSL 1 / WSL 2 in Windows 10

Mount any Linux file system on Windows 10

The previous steps will just try to mount a physical drive as ext4. If you want to specify a different file system, you’ll need to use a command other than Windows Subsystem for Linux 2.

To mount a specific Linux file system on Windows 10, follow these steps:

1. Open Start.

2. Search for PowerShell , right-click on the top result and select the option Run as administrator .

3. Type the following command to list available physical drives on Windows 10 and press Enter:

wmic diskdrive list brief

4. Confirm the drive path in the “Device ID” column .

5. Type the following command to mount the drive and press Enter:

wsl --mount DISKPATH -t FILESYSTEM

In this command, be sure to replace DISKPATH and FILESYSTEM for the drive path and the Linux file system you want to mount. For example, to mount the drive as fat, use the following command:

wsl --mount DISKPATH -t vfat

After you complete the steps, the drive containing the Linux files will mount and you can access it using File Explorer.

Access the Linux file system on Windows 10

To access files from the Linux file system on Windows 10, follow these steps:

1. Open File Explorer.

2. Click the Linux item from the left navigation pane.

3. In the address bar, navigate to wsl $ and then access to the mount directory. For example:

wsl$DISTRO-NAMEMOUNT-POINT
Navigate to wsl $ and then access the mount directory

After completing the steps, you will be able to browse Linux files from the file system that is not natively supported on Windows 10. In addition to using File Explorer, once the drive is mounted, you will be able to access the systems. file like “ext4” from the WSL2 console using the command lines.

Unmount Linux file system on Windows 10

To unmount Linux file system on Windows 10, follow these steps:

1. Open Start.

2. Search for PowerShell , right-click on the top result and select the option Run as administrator .

3. Type the following command to unmount and remove the drive, and then press Enter :

wsl --unmount DISKPATH

In the command, make sure to replace DISKPATH with the Device ID of the drive you want to unmount .

After you complete the steps, the drive with the Linux file system will be unmounted and removed from Windows 10.

This feature is available starting with Windows 10 build 20211 and is expected to be available in future operating system releases. If you can’t see the new feature, it’s because you’re running the latest preview available in Dev Channel.

1