How To Access Linux Filesystems In Windows 10 And WSL 2

How To Access Linux Filesystems In Windows 10 And WSL 2

The feature lets users access Linux file systems, such as ext4, that aren’t natively supported by Windows. It also means those who are dual-booting Windows and Linux with different disks can now access Linux files from Windows.

Starting with Windows build 20211, Windows Subsystem for Linux 2 (WSL 2) will be offering a new feature: wsl –mount. This new parameter allows a physical disk to be attached and mounted inside WSL 2, which enables you to access filesystems that aren’t natively supported by Windows (such as ext4).

So, if you’re dual booting with Windows & Linux using different disks, you can now access your Linux filesystem in WSL 2.

The feature comes with limitations. For instance, as of now, it’s not possible to attach a single partition or mount ext4 partitions that are on the same physical disk as Windows OS. This is because the new improvement is only limited to separate physical disks. Also, you cannot attach USB flash drives even though it supports USB disks.

How to mount a Linux disk in WSL 2

To mount a disk, open a PowerShell window with administrator privileges and run:

wsl --mount <DiskPath>

Listing the available disks in Windows is easy. Just run:

wmic diskdrive list brief

To unmount and detach the disk from WSL 2, run:

wsl --unmount <Diskpath>

The disks paths are available under the ‘DeviceID’ columns. Usually under the \\.\\\.\PHYSICALDRIVE* format. Below is an example of mounting a specific partition of a given hard disk into WSL and browsing its files.

How to mount a Linux disk in WSL 2

Accessing Linux filesystem with File Explorer

Once mounted, it’s also possible to access these disks through the Windows explorer by navigating to \wsl$ and then to the mount folder.

Accessing files with File Explorer

Bottom line

Now, if you want to get started with access a Linux filesystem in WSL 2, first update your Windows to the latest Build 20211 and then check out the official docs.

Leave a Reply

Your email address will not be published.

Latest from Tips & Tricks