Mounting an external ext4 disk through WSL2 on Windows, and mapping the mount point to a Windows drive letter, gives you native Linux read/write access plus access from Windows Explorer. Here is the complete workflow.
Preparation (after each time you connect the disk)
1. Find the external disk number
Open PowerShell as Administrator and run the following command to identify the disk number:
| |
In the returned list, find the model of your portable disk (for example, Innostor Ext. HDD USB Device) and look at the number at the end of the corresponding DeviceID (for example, \\.\PHYSICALDRIVE2 means disk number 2).
2. Take the disk offline in Windows
In an Administrator PowerShell:
| |
Note: if the disk number is not 2, replace the number in
select disk 2with the actual number found in step 1.
3. Attach the raw disk to the WSL2 kernel
In an Administrator PowerShell:
| |
Mount the filesystem and configure permissions (Linux side)
4. Find the ext4 partition and mount it
Enter Linux with wsl, run lsblk -f to confirm the partition whose TYPE is ext4 (assume it is sdd3), then run:
| |
Map to a Windows drive letter
5. Map drive Z: (must use a normal user)
Press Win + R, type powershell, and press Enter (do not run as Administrator), then run:
| |
After that, you can double-click Z: in This PC and read/write it directly.
Safely remove/eject the disk
1. Remove the drive letter (normal user terminal)
| |
2. Unmount the mount point in Linux (run inside wsl)
| |
3. Detach the disk from WSL in Windows (Administrator PowerShell)
| |
4. Make Windows recognize the disk again (Administrator PowerShell)
| |