Microsoft announces a few days ago a new build to the windows insiders in the Dev channel with a long-awaited feature for users.
This build number 20211 adds a new feature to the Windows Subsystem for Linux (WSL 2) calls "wsl --mount" that's 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 files from Windows.
To use this feature, you must be in Windows 10 Insider Preview Build 20211 or newer and install and enable WSL 2 in your system, then follow the instructions below :
- open PowerShell as an administrator.
- to check and list the available disks in Windows, run the following command: wmic diskdrive list brief
- After choosing the hard disk that desire to mount and write " wsl --mount <DiskPath>" in the PowerShell Window.
- Once your disk mounted successfully, just open the Windows Explorer and navigate to \wsl$ and then to the mount folder to access your disk(s).
- If you want to unmount and detach your disk(s) from WSL, run this command in PowerShell.
Note: The disks paths are available under the ‘DeviceID’ columns. Usually under the \\.\\\.\PHYSICALDRIVE* format.
This feature is in its early days, and it sould be ready to ship with the next year first major update of Windows 10 as known as Windows 10 21H1 expected next spring, and it has some limitations such as that only entire disks can be attached to WSL 2, meaning that it's not possible to attach only a partition, so you can not use this command to access just to a specific partition, the USB flash drives are not supported as well and will fail to attach to WSL 2, and finally, only filesystems that are natively supported in the kernel can be mounted by wsl --mount. This means that it's not possible to use installed filesystem drivers (such as ntfs-3g for example) by calling wsl --mount.