How to mount SMB shares in Windows Subsystem for Linux (WSL) - for Debian-based distributions

Following the previous blog post about installing and configuring WSL 2 on Windows 10, we now can start using it for our file operations. I find it much easier to use GNU/Linux tools for file manipulation such as ‘‘diff’’ and ‘‘sed’’ than their Windows equivalents.

In this post, we will mount an existing SMB share so we can view its contents, move, copy or edit the files in the share.

So without further ado, start your Debian-based distribution and create a mount point:

sudo mkdir /mnt/temp

Once the mount point is created, we can mount the share to that with:

sudo mount -t drvfs '\\192.168.1.1\ShareName\' /mnt/temp

Please note that you need to have accessed the share from Windows in the past and have checked “Remember these credentials” for this to work, as the required username/password needs to be saved in your system’s credential manager. WSL currently does not provide a way to specify the credentials in the above command.

To access the files, switch to this mount point:

cd /mnt/temp

You should now be able to access the files using your favorite command-line tools.

If you need to unmount the share after you finish, type the following:

sudo umount /mnt/temp

Thank you for reading! Be sure to share this post if you found it helpful and don’t hesitate to chat with me about it!

This post was first published on Stathis’ log book by Stathis Athanasiadis aka StatAth

Updated:

Comments