Scott Hanselman

WSL2 can now mount Linux ext4 disks directly

November 02, 2021 Comment on this post [3] Posted in Linux
Sponsored By

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.

--mount <Disk>
Attaches and mounts a physical disk in all WSL2 distributions.
Options:
--bare
Attach the disk to WSL2, but don't mount it.

--type <Type>
Filesystem to use when mounting a disk, if not specified defaults to ext4.

--options <Options>
Additional mount options.

--partition <Index>
Index of the partition to mount, if not specified defaults to the whole disk.

--unmount [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.

WSL --mount for ext4 and Linux File Systems on WSL2

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.

About Scott

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.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
November 09, 2021 8:24
Thanks again for stopping upgrades on Windows 10, while many can't upgrade to Windows 11!
November 10, 2021 12:31

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.
Fm Whatsapp
apk
November 10, 2021 13:41
Check Our Computer PC Building Guide Here : https://www.laptopbeats.com/

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.