How to Mount Network Drives in Windows Subsystem for Linux

This post shows students and new users steps to mount or map a network drive or folder in wsl/” class=”sal-link” rel=”noopener” target=”_blank” data-sal-id=”2908″>Windows Subsystem for Linux (WSL). In Windows 11, users can map network drives and folders with ease. If you know the path to a shared folder and have access to the location, you should be able to map it easily.

Similarly, users can mount or map network locations in WSL environments. Any network location within Windows can be mounted or mapped in the WSL Linux shell.

In a WSL environment, users can mount network locations in two or more ways. One way is to map a network folder, like mounting a removable drive in WSL. Once the drive is mounted with a drive letter, you can use the mount command to map the drive to a mount point in Linux.

The commands below can mount a network drive assigned to the letter F in the WSL environment.

sudo mkdir /mnt/f
sudo mount -t drvfs F: /mnt/f

Mapping a network folder follows a similar approach.

How to map a network folder in Windows Subsystem for Linux

As mentioned above, any network location you can reach from within Windows can be mounted or mapped from the Linux shell.

If you know the UNC (Universal Naming Convention) path for a particular folder or drive and can access the location, you can mount it in the WSL shell environment.

For example, if the path to the network share is \serverdocuments, you can run the commands below to mount it in WSL.

First, create a mount point in Linux where you’d want to map the shared network folder. Run the commands below to create a mount point if it’s not already created.

sudo mkdir /mnt/documents

Once the mount point is created, run the commands below to mount the network share.

sudo mount -t '\serverdocuments' /mnt/documents

If the network location is password protected, you may have to use the net use command to map the location instead.

For example, you can use the net use command to mount the network path \serverdocuments with the username Joe and the password MyPassword to map it to your F: drive.

net.exe use f: \serverdocuments /user:Jdoe MyPassword

That should mount the network location mapped to the F drive in WSL. To unmount, simply run the commands below.

sudo umount /mnt/documents

That should do it!

The post below also shows you how to mount a removable drive in WSL.

How to mount a removable drive in Windows Subsystem for Linux.

Conclusion:

  • Mapping or mounting network drives and folders in Windows Subsystem for Linux (WSL) is straightforward.
  • Users can easily access shared folders by knowing the UNC path and using the appropriate commands.
  • It is essential to create a mount point in WSL before mapping network locations.
  • For password-protected shares, the net use command can facilitate access by providing credentials.
  • Unmounting is as simple as using the umount command followed by the mount point.
  • Familiarizing yourself with these commands can enhance your productivity when working in WSL.

By following these steps, students and new users can effectively leverage the capabilities of WSL to manage network resources efficiently.

Frequently Asked Questions

How do I mount a network drive in WSL?

To mount a network drive in Windows Subsystem for Linux (WSL), first create a mount point using the command 'sudo mkdir /mnt/your_mount_point'. Then, use the command 'sudo mount -t drvfs X: /mnt/your_mount_point', replacing 'X' with the drive letter of the network drive.

What is the UNC path and how do I use it in WSL?

The UNC (Universal Naming Convention) path is a format used to specify the location of resources on a network. In WSL, you can mount a network share using the UNC path by creating a mount point and running 'sudo mount -t 'server older' /mnt/your_mount_point'.

Can I access password-protected network shares in WSL?

Yes, you can access password-protected network shares in WSL by using the 'net use' command. For example, you can run 'net.exe use F: server older /user:username password' to map the network share to a drive letter.

How do I unmount a network drive in WSL?

To unmount a network drive in WSL, you can use the command 'sudo umount /mnt/your_mount_point'. Make sure to replace 'your_mount_point' with the actual mount point you used when mounting the drive.

Is it necessary to create a mount point before mounting a network drive in WSL?

Yes, it is essential to create a mount point in WSL before mounting a network drive. You can create a mount point using the command 'sudo mkdir /mnt/your_mount_point' to ensure the network location has a designated path in the Linux file system.

Categories:

Tags:

  1. Ben Crocker Avatar
    Ben Crocker

    Hi!

    You’re missing one thing from this otherwise extraordinarily useful post:

    sudo mount -t ‘\\server\documents’ /mnt/documents

    should be

    sudo mount -t drvfs ‘\\server\documents’ /mnt/documents

    (I got the bit about “-t drvfs” from another post that involved doing
    “Map network drive” first to assign a drive letter to the network drive.)

Leave a Reply

Your email address will not be published. Required fields are marked *