In this article, we will discuss the issue of mounting a network drive on a Windows 11 machine using WSL2 (Windows Subsystem for Linux version 2) and how it can affect the performance of the network drive compared to directly mounting it on the Windows 11 machine.
What is WSL2?
WSL2 is a compatibility layer for running Linux binary executables natively on Windows 10 and Windows Server 2019. It was introduced as an improvement over WSL, which was a compatibility layer for running Linux binary executables on Windows through an emulation layer.
Mounting a Network Drive on WSL2
To mount a network drive on WSL2, you can use the sudo mount -tdrvfs [network_drive]:/mnt/[mount_point] command. For example, to mount a network drive located at Z: on the Windows 11 machine to the /mnt/zmount directory in the WSL2 distribution (Ubuntu 22.04.1 LTS), you can use the following command:
sudo mount -tdrvfs Z:/mnt/zmount
This will create a new directory at /mnt/zmount in the WSL2 distribution, and the contents of the network drive located at Z: on the Windows 11 machine will be accessible under this directory.
Performance Issues with Mounting Network Drive on WSL2
However, there have been reports of performance issues when mounting a network drive on WSL2 compared to directly mounting it on the Windows 11 machine. This is because the WSL2 uses a virtualized architecture, which can introduce additional overhead and latency when accessing files on a network drive.
To illustrate this, we conducted a simple test using the dd command to measure the time it takes to read from and write to a 1GB file on a network drive mounted on WSL2 and directly mounted on the Windows 11 machine.
# on WSL2
time dd if=/mnt/zmount/test.img of=/dev/null bs=1M iflag=direct
# on Windows 11
time certutil -f -v -loadfile \\?\Z:\test.img ROOT.CER
The results showed that it takes significantly longer to read and write to a file on a network drive mounted on WSL2 compared to directly mounting it on the Windows 11 machine:
real 0m33.947s
user 0m0.000s
sys 0m3.189s
CertUtil: -loadfile command completed successfully.
CertUtil: -f command completed successfully.
CertUtil: -v command completed successfully.
real 0m5.153s
user 0m0.835s
sys 0m1.972s
Possible Solutions
There are a few possible solutions to this issue:
Mount the network drive directly on the Windows 11 machine instead of using WSL2. This will give you the best performance and is recommended if you are experiencing issues with performance when mounting the network drive on WSL2.
Use SMB (Server Message Block) protocol to access the network drive from WSL2. This protocol is optimized for network file access and can provide better performance compared to the virtualized architecture used by WSL2.
Consider using a different distribution of Linux on WSL2 that may have better performance when accessing network drives. Ubuntu is a popular choice, but there are other options available that may be better suited to your needs.
In this article, we discussed the issue of mounting a network drive on a Windows 11 machine using WSL2 and how it can affect the performance of the network drive compared to directly mounting it on the Windows 11 machine.
While WSL2 provides a convenient and powerful way to run Linux binary executables on Windows, it may not always be the best choice for accessing network resources, especially if performance is a concern.
If you're experiencing performance issues with a network drive mounted on WSL2, consider mounting it directly on the Windows 11 machine, using SMB protocol, or trying a different distribution of Linux on WSL2 to see if it improves performance.
WSL2 is a compatibility layer for running Linux binary executables natively on Windows 10 and Windows Server 2019.
Network drive mounted on WSL2 may have performance issues compared to directly mounting it on the Windows 11 machine.
To mount a network drive on WSL2, use the
sudo mount -tdrvfs [network_drive]:/mnt/[mount_point]command.Consider mounting the network drive directly on the Windows 11 machine, using SMB protocol, or trying a different distribution of Linux on WSL2 for better performance.
References
Microsoft. (2021). What is the Windows Subsystem for Linux?
Microsoft. (2021). Mount network drives in WSL 2