WSL2 can now mount Linux ext4 disks directly
If you're on a version of Windows 11 that is build 22000 or greater, you can now use WSL to mount Linux disks directly. Run winver to see your Windows version. I'm on 22000.282 as of the time of this writing.
I can also run wsl --help and see the --mount instructions. If you don't have them, you're not on the latest, or you can try installing/update WSL from the Windows Store. Installing WSL from the Windows Store gets you updates faster.
Attaches and mounts a physical disk in all WSL2 distributions.
Attach the disk to WSL2, but don't mount it.
Filesystem to use when mounting a disk, if not specified defaults to ext4.
Additional mount options.
Index of the partition to mount, if not specified defaults to the whole disk.
Unmounts and detaches a disk from all WSL2 distributions.
Unmounts and detaches all disks if called without argument.
You'll need to be an admin to mount a disk. You can first get a list of all the disks using this PowerShell query:
GET-CimInstance -query "SELECT * from Win32_DiskDrive"
The DeviceID is a path like \\.\SOMETHING and that's what matters.
Then you just
wsl --mount \\.\SOMETHING".
The device will appear under /mnt/wsl/SOMETHING in your Linux instance. You can mount unpartitioned disks like this, or you can mount partitioned disks. Then you can run lsblk and see the partitions and they'll be under /dev/<Device><Partition>. Once you know the partition number you can go back and
wsl --mount --\\.\SOMETHING --partition --type Filesystem. The filesystem parameter is for things like vfat, etc for filesystems that have kernel support.
Today SD Cards and Flash Drives aren't working, but USB externals work and internal drives work, as well as VHDs.
Sponsor: Couchbase Capella DBaaS is flexible, full-featured and fully managed with built-in access via K/V, SQL and full text search. It’s blazing fast, yet surprisingly affordable. Try Capella today for free.
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well.
Comments are closed.