Skip to content

Shared Windows Drives

nylander edited this page Jun 20, 2023 · 14 revisions

Linux

  • Last modified: tis jun 20, 2023 09:47
  • Sign: JN
  • Tested on: Xubuntu 22.04
  • Solved: Yes

Windows users at NRM have access to both private and shared partitions provided by the server systems. The common partitions are labeled X: and Y:, where the X: partition points at a file area that is common to all NRM users. The Y: partition is a direct link to the users department folder, which is one part of what you find on X:.

Shared Windows partitions are available for non-Windows users via the samba protocol on smb://nrmsmb01/nrm-files/NRM, using your NRMUSERNAME, and group NRM. The file path nrm-files/NRM would be the equivalent to X:.

The private partition on the Windows server is accessible on smb://nrmsmb01/Users/NRMUSERNAME.

One simple tutorial for using the default file manager in Ubuntu for accessing shared Windows folders is given here. See also here.

CLI access using smbclient

Install smbclient

$ sudo apt install smbclient

List available resources on smb server

$ smbclient -L \\\\nrmsmb01 -W NRM -m smb2 -U NRMUSERNAME

Connect to a resource on the server

$ smbclient \\\\nrmsmb01\\Users -W NRM -m smb2 -U NRMUSERNAME
$ smbclient \\\\nrmsmb01\\nrm-files\\NRM\\FA\\BIO -W NRM -m smb2 -U NRMUSERNAME

Note: To cd into a folder with a white space in the folder name, prepend the folder name with a quote (").

Mount SMB over SSH

You may mount a smb volume on your local computer by using cifs (Common Internet File System utilities). Note that you need root (sudo) permissions for the mounting syntax used. Note also that the examples given below will only work from within the NRM-IT firewall.

$ sudo apt install cifs-utils
$ test -e ~/X || mkdir --mode 700 ~/X
$ sudo mount -t cifs //nrmsmb01/nrm-files/NRM ~/X \
  -o domain=NRM,noexec,nodfs,noperm,username=NRMUSERNAME
$ touch ~/X/FA/BIO/BIO_Privat/apa
$ rm ~/X/FA/BIO/BIO_Privat/apa
$ sudo umount ~/X

And, an example for accessing the BIO-department folder as "Y":

$ test -e ~/Y || mkdir --mode 700 ~/Y
$ sudo mount -t cifs //nrmsmb01/nrm-files/NRM/FA/BIO ~/Y \
  -o domain=NRM,noexec,nodfs,noperm,username=NRMUSERNAME
$ touch ~/Y/BIO_Privat/apa
$ rm ~/Y/BIO_Privat/apa
$ sudo umount ~/Y

As an alternative of using the command line to mount/unmount, one may put relevant entries in the /etc/fstab in order to do an automatic mount at upstart. In addition, if you are comfortable with storing your password in plain text, you may create a "credentials" file in your home directory. Examples are given below:

Example credentials file (here called ~/.nrm-share). Make sure to replace NRMUSERNAME and NRMPASSWORD:

username=NRMUSERNAME
password=NRMPASSWORD
domain=NRM

Example entries to add to your /etc/fstab:

//nrmsmb01.nrm.se/nrm-files /home/UNIXUSERNAME/X cifs credentials=/home/UNIXUSERNAME/.nrm-share,iocharset=utf8,uid=NRMUSERNAME 0
//nrmsmb01.nrm.se/Users/NRMUSERNAME /home/UNIXUSERNAME/NRM-Win cifs credentials=/home/UNIXUSERNAME/.nrm-share,iocharset=utf8,uid=NRMUSERNAME 0