Mount an share (cifs) into WSL

AtyKlaxas 1 Reputation point
2022-02-12T08:56:36.5+00:00

Hello

I try to mount \192.168.2.22\Volume_1 into wsl
in windows file explorer, explore this share work perfect
so it should work in WSL, right?
But everything in google does not work

this is my script :

DIR='/mnt/somename'
SHARE='\\192.168.2.22\Volume_1'

sudo mkdir -p $DIR #prevent first try
sudo umount $DIR # prevent already mounted
sudo mount -t drvfs $SHARE $DIR -o username=alexis,password=<password> #mount it

PS: i miss taged this post because idk how to tag it, i try : wsl linux share nas mount

Windows 10 Network
Windows 10 Network
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Network: A group of devices that communicate either wirelessly or via a physical connection.
2,272 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 43,931 Reputation points
    2022-02-18T14:58:48.067+00:00

    Hello @AtyKlaxas

    If the host Windows OS can access a file share at "\servername\sharename", try this command in bash. and you will need to restart the device once this is done.

    mkdir /mnt/mountedshare
    mount -t drvfs '\servername\sharename' /mnt/mountedshare

    In order to mount a Windows drive using DrvFs, you can use the regular Linux mount command. For example, to mount a removable drive D: as /mnt/d directory, run the following commands:

    $ sudo mkdir /mnt/d$ sudo mount -t drvfs D: /mnt/d

    File System Improvements to the Windows Subsystem for Linux
    https://learn.microsoft.com/en-gb/archive/blogs/wsl/file-system-improvements-to-the-windows-subsystem-for-linux

    Hope this resolves your Query!!

    --
    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments

  2. AtyKlaxas 1 Reputation point
    2022-02-18T21:48:08.947+00:00

    this is my terminal

    alexis@LAPTOP-JEQPFFER:/mnt$ sudo mount -t drvfs '\\192.168.2.22\Volume_1' /mnt/nas/
    [sudo] password for alexis:
    alexis@LAPTOP-JEQPFFER:/mnt$ ls
    c  d  e  f  g  h  nas
    alexis@LAPTOP-JEQPFFER:/mnt$ cd nas
    alexis@LAPTOP-JEQPFFER:/mnt/nas$ ls
    ls: reading directory '.': Invalid argument
    alexis@LAPTOP-JEQPFFER:/mnt/nas$ sudo ls
    ls: reading directory '.': Invalid argument
    alexis@LAPTOP-JEQPFFER:/mnt/nas$ cd ..
    alexis@LAPTOP-JEQPFFER:/mnt$ ls -al
    total 0
    drwxr-xr-x 1 root   root   4096 Feb 12 09:11 .
    drwxr-xr-x 1 root   root   4096 Jun  2  2021 ..
    drwxrwxrwx 1 alexis alexis 4096 Feb 18 21:44 c
    drwxrwxrwx 1 alexis alexis 4096 Feb 18 21:44 d
    drwxrwxrwx 1 alexis alexis 4096 Feb 18 21:44 e
    drwxrwxrwx 1 root   root   4096 Jun  2  2021 f
    drwxrwxrwx 1 alexis alexis 4096 Feb 18 21:44 g
    drwxrwxrwx 1 root   root   4096 Aug 30 17:55 h
    drwxrwxrwx 1 root   root    512 Feb 11 20:19 nas
    alexis@LAPTOP-JEQPFFER:/mnt$ sudo su
    root@LAPTOP-JEQPFFER:/mnt# cd nas
    root@LAPTOP-JEQPFFER:/mnt/nas# ls
    ls: reading directory '.': Invalid argument
    root@LAPTOP-JEQPFFER:/mnt/nas#
    

    the /mnt/nas folder is created by an sudo mkdir
    the mount command doent sent error
    but if i ls the folder
    nothing return

    0 comments No comments