If you have an environment which has a mix of Linux and Windows machines, you sometimes have to access network share from a Linux machine. In my case, I wanted to take advantage of the tools that are available in Linux (e.g. bash script using readarray and jq) and use them on files that are located on an SMB share in a Windows-dominated environment.
Mount a Mapped Drive into WSL

In Windows, I have the following Network Share mapped to Q: drive
Note: I have already installed Ubuntu 22.04 WSL in Windows 11 which is a prerequisite prior to the following commands to work.
Open a command prompt and enter WSL by typing ‘bash’ and then hit Enter.
Then enter the following commands and enter your password for your WSL:
$ sudo mkdir /mnt/q$
$ sudo mount -t drvfs Q: /mnt/q[sudo] password for user:
List the files and folders and confirm whether the network share is mounted successfully$ ls /mnt/q
Mounting network locations
This method does not require that you have a mapped drive. I do suggest that you ensure that you have the correct network path (aka UNC path).
Open a command prompt and enter WSL by typing ‘bash’ and then hit Enter.
Then enter the following commands and enter your password for your WSL:
$ sudo mkdir /mnt/share
$ sudo mount -t drvfs '\server\share' /mnt/share[sudo] password for user:
List the files and folders and confirm whether the network share is mounted successfully$ ls /mnt/share

Leave a Reply