Mount a Windows Fileshare


Requirements


Share the Directory on Windows

  1. Open File Explorer.
  2. Right click on the directory you want to share.
  3. Click 'Show more options'.
  4. Click 'Give access to' -> 'Specific people...'
  5. On the drop-down menu, find 'Everyone'.
  6. (Optional) change 'Read' to 'Read/Write'.
  7. Click 'Share'.

Check the IP address on Windows by opening CMD and running

1ipconfig

Mount the Shared Windows Directory on Linux

Install cifs-utils and smbclient.

Add the windows password to pass, then check the output.

1pass windows

Create a mount directory:

1windir=/mnt/windows
2sudo mkdir ${windir}
3sudo chown $USER ${windir}

Specify the username and IP address, then mount that directory:

1winuser=Alice
2windows_ip=192.168.0.13
3
4sudo mount -t cifs -o username=${winuser},uid=$UID,password="$(pass windows)" //${windows_ip}/Users ${windir}
5
6ls ${windir}

Check it works, then unmount:

1sudo fusermount3 -u ${windir}

Alias

Make an alias for easy mounting and unmounting.

1alias mwin='sudo mount -t cifs -o username=${winuser},uid=$UID,password="$(pass windows)" //${windows_ip}/Users ${windir}'
2alias mwinrm='sudo fusermount3 -u ${windir}'