Access Linux Filesystems in Windows and WSL 2 - Windows Command Line
Access Linux Filesystems in Windows and WSL 2 - Windows Command Line
DevOps
Access Linux
Languagesfilesystems in Windows and WSL 2
.NET
Platform Development
Pierre
September 10th, 2020
Data Development
Starting with Windows Insiders preview build 20211, 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 files from Windows!
Getting started
To mount a disk, open a PowerShell window with administrator privileges and run:
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.
Limitations
By default, wsl --mount attempts to mount the disk as ext4. To specify a filesystem, or
for more advanced scenarios, check out Mount a disk in WSL 2.
Also please note that this feature comes with the limitation that only physical disks can
be attached to WSL 2. At this time, it’s not possible to attach a single partition. More
details on the limitations here.
Pierre Boulay
Software Engineer II, Linux on Windows
Read next
Newer Comments →
Of course
Cool! Now, if only SFTP support was added to Explorer as well, I would be happy.
You can mount an SFTP share in WSL, and then access it through the \WSL$ path in the Windows Explorer.
Pierre, does this actually work? I just tried mounting an SSHFS system in WSL2. It mounts fine
and files are available in Ubuntu, but when I use Explorer and browse to the mounted folder, I
get the error message:
“\wsl$\Ubuntu\mnt\test_mount is not accessible. You might not have permission to use this
network resource. Contact the administrator of this server to find out if you have access
permissions.
And server is aliased in my .ssh/config to the hostname, port, and username for that server
Note that when unmounted, windows explorer can open the folder, but of course the
contents are empty.
Thanks!
To make the mountpoint accessible in the explorer, the uid needs to match the
default wsl user for your distro.
Should be close to native from inside WSL 2. From the Windows Explorer there is some penalty
If the whole device is exposed to the Linux kernel, does that mean I could mount an encrypted LUKS volume inside WSL
and navigate the fs using explorer.exe?
That would be awesome. It would mean one doesn’t need VeraCrypt for disk encryption interop between windows and
linux.
Unfortunately the kernel that we currently ship doesn’t, but you can build you own (just make sure that
CONFIG_DM_CRYPT is ‘y’), and then install in %windir%\system32\lxss\tools\kernel
will a future kernel support dm-crypt natively? I imagine quite a few people run Linux from
encrypted and LVM-d filesystems.
Interesting. Any plans on have it enabled in the default distribution in the future?
I guess that before WSL having support for disks mounts it made no sense to enable it, but
now I would include any disk mapper supported by the linux kernel.
Unfortunately not, because lvm relies on a daemon that isn’t running in WSL 2.
It might be possible to get it to work if you manually start lvmetad, but this scenario isn’t supported at this
time.
All filesystems supported by the kernel you’re running can be mounted from WSL (in your case, xfs is
supported by the kernel we ship).
For more complex use cases, you can run wsl --mount <Device> --bare, and then manually mount the
device from inside WSL.
Does the limitation of only working with disks mean it’s not possible to mount Linux partitions if they are on the same
physical disk (boot disk) as Windows, e.g. on a laptop?
Does this make it possible to use a physical disk for a WSL root filesystem? It would be truly amazing if one could have a
full-fledged dual-boot setup that could also double as WSL.
It’s not possible to boot directly on a mounted disk, but you can chroot into it after mounting it.
Ihor Dutchak October 19, 2020 6:26 am
Would be cool to have a way to chroot to a specific device quickly, like wsl –chroot
\.\PHYSICALDRIVE… without need to mount a drive -> mount all the /dev/… /proc/… etc. ->
chroot…
Can WSL2 mount other filesystem like JFS with this function?
The kernel that we officially ship doesn’t support JFS at this time, but if you build your own, you should be
able to mount a JFS volume.
Hello Pierre
Is this functionality only limited to storage devices, or would it enable me to make use of peripheral devices which connect
through the same USB receptacles?
An example would be if I could use a wired joystick-controller that makes use of the USB type-A interface, the same way I
use USB type-A for my flash drive.
This feature is only limited to storage devices. Unfortunately it can’t be used to pass-through a USB device
to WSL 2.
Newer Comments →
Topics
Accessibility AF_UNIX ANSI/VT Sequences automount background tasks Bash BASIC Buffers Build2017 Build2019 Build2020 chmod
Chocolatey cmd Color Command-Line ConPTY Console containers Creators Update daemons DrvFs DvfFs Encoding filesystem
font ifconfig inotify interop Linux LinuxTools metadata MS-DOS networking Open-Source OpenSSH PowerShell PseduoConsole
Pseudo Console PTY release Rendering settings sockets Store Syscalls Tabs & Sets Teletype Terminal Themes Tmux TTY
Ubuntu Unicode UTF-8 VIntage Visual Studio What's New Win10S Windows Windows 10 Windows 10 S Windows Package Manager
Kayla Cinnamon
Program Manager
Craig Loewen
Program Manager
Demitrius Nelon
Senior Program Manager
Pierre Boulay
Software Engineer II
Tyler Citrin
Program Manager
Archive
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
Stay informed
Surface Laptop Go Download Center Office for students AppSource Windows Dev Center About Microsoft
Surface Pro X Microsoft Store support Office 365 for schools Automotive Developer Center Company news
Surface Go 2 Returns Deals for students & Government Microsoft developer Privacy at Microsoft
parents program
Surface Book 3 Order tracking Healthcare Investors
Microsoft Azure in Channel 9
Microsoft 365 education Manufacturing Diversity and inclusion
Virtual workshops and Microsoft 365 Dev Center
Windows 10 apps Financial services Accessibility
training
Microsoft 365 Developer
HoloLens 2 Retail Security
Microsoft Store Promise Program
English (United States) Sitemap Contact Microsoft Privacy Terms of use Trademarks Safety & eco About our ads © Microsoft 2020