Difference between revisions of "File transfer via SMB"

From Storrs HPC Wiki
Jump to: navigation, search
(Example: If you have a UITS HNAS share)
Line 3: Line 3:
  
 
'''Network-attached storage (NAS)''', such as Synology NAS, typically provides access to files using network file sharing protocols like SMB.
 
'''Network-attached storage (NAS)''', such as Synology NAS, typically provides access to files using network file sharing protocols like SMB.
=Connecting the SMB server from the Hornet=
+
=Connecting the SMB server from the HPC Cluster=
 
To access the SMB server, you need to use the following command:
 
To access the SMB server, you need to use the following command:
 
  $ smbclient -W [ENGR_STUDENT | UCONN] -U <NetID> //server.uconn.edu/folder/path  
 
  $ smbclient -W [ENGR_STUDENT | UCONN] -U <NetID> //server.uconn.edu/folder/path  

Revision as of 17:41, 19 February 2016

What is SMB

SMB is an important protocol because of the large number of PCs out there that already have client and server implementations running on them. All Windows for Workgroups, Windows 95 and Windows NT systems are (or are capable of) running SMB as either a client, a server, or both.

Network-attached storage (NAS), such as Synology NAS, typically provides access to files using network file sharing protocols like SMB.

Connecting the SMB server from the HPC Cluster

To access the SMB server, you need to use the following command:

$ smbclient -W [ENGR_STUDENT | UCONN] -U <NetID> //server.uconn.edu/folder/path 

where [ENGR_STUDENT | UCONN] refers to the different domains of engr domain or the uconn domain,

server.uconn.edu refers to the servername of your NAS devices,

the folder is the path you want to go, and

<NetID> refers to your access NetID. The domain and the username should be acceptable by your NAS devices.

Example: If you have a UITS HNAS share

Where <user_name> is your Engineering user name, and <share_name> is the name of your UITS HNAS share:

smbclient -W ENGR_STUDENT -U <user_name> //hnas.engr.uconn.edu/EngrGroupMixed/
Password: <Enter password here>
Domain=[ENGR_STUDENT] OS=[Hitachi NAS Platform 12.2.3753.08] Server=[Hitachi NAS Platform 12.2.3753.08]
smb: \> cd <share_name>

Copying the files

To copy the file from the local file systemt to the SMB server:

smb: \> put local_file remote_file

To copy the file from the SMB serverto the local file systemt:

smb: \> get remote_file local_file

For example

$ smbclient -W ENGR_STUDENT -U tix11001 //hnas.engr.uconn.edu/EngrGroupMixed
Enter tix11001's password:
Domain=[ENGR_STUDENT] OS=[Hitachi NAS Platform 12.2.3753.08] Server=[Hitachi NAS Platform 12.2.3753.08]
smb: \> cd becatshare\
smb: \becatshare\> ls
  .                                   D        0  Tue Oct  6 14:03:05 2015
  ..                                  D        0  Tue Oct  6 14:03:05 2015
  parallel_studio_xe_2015_update3.tgz      A 4156836825  Mon Apr 20 02:15:32 2015
  .DS_Store                          AH    12292  Fri Oct  9 15:04:33 2015
  iso                                 D        0  Tue Sep 29 10:21:44 2015
  Passwords.kdbx                      A     8462  Tue Oct  6 14:03:05 2015
  hpc                                 D        0  Tue Oct  6 10:55:40 2015
  .TemporaryItems                    DH        0  Wed Sep 23 13:44:36 2015 

                65535 blocks of size 1073741824. 61536 blocks available
smb: \becatshare\> !ls
smb: \becatshare\> !pwd
/shared/admin/RedHat
smb: \becatshare\> get parallel_studio_xe_2015_update3.tgz
getting file \becatshare\parallel_studio_xe_2015_update3.tgz of size 4156836825 as parallel_studio_xe_2015_update3.tgz (59640.2 KiloBytes/sec) (average 59640.2 KiloBytes/sec)
smb: \becatshare\> !ls
parallel_studio_xe_2015_update3.tgz
smb: \becatshare\> exit

Copying the directory

From the SMB server to the local file system:

smb: \> mask ""
smb: \> recurse ON
smb: \> prompt OFF
smb: \> cd 'path\to\remote\dir'
smb: \> lcd '~/path/to/download/to/'
smb: \> mget *
smb: \> recurse OFF

From the local file system to the SMB server:

smb: \> mask ""
smb: \> recurse ON
smb: \> prompt OFF
smb: \> cd 'path\to\remote\dir'
smb: \> lcd '~/path/to/download/to/'
smb: \> mput *
smb: \> recurse OFF

For example

$ smbclient -W ENGR_STUDENT -U tix11001 //hnas.engr.uconn.edu/EngrGroupMixed
Enter tix11001's password:
Domain=[ENGR_STUDENT] OS=[Hitachi NAS Platform 12.2.3753.08] Server=[Hitachi NAS Platform 12.2.3753.08]
smb: \> cd becatshare\hpc
smb: \becatshare\hpc\> ls
  .                                   D        0  Tue Oct  6 10:55:40 2015
  ..                                  D        0  Tue Oct  6 10:55:40 2015
  security                            D        0  Fri Apr 19 13:49:35 2013
  gpfs_training                       D        0  Thu Dec 19 23:15:50 2013
  gpfs_training#                      D        0  Tue Oct  6 10:55:40 2015
  iso                                 D        0  Thu Jan  2 12:53:12 2014
  .DS_Store                          AH     8196  Tue Oct  6 11:05:28 2015
  SpectrumScaleDocumentation          D        0  Tue Oct  6 10:55:05 2015
  temp                                D        0  Thu Sep 10 14:09:22 2015

                65535 blocks of size 1073741824. 61536 blocks available
smb: \becatshare\hpc\> mask ""
smb: \becatshare\hpc\> recurse ON
smb: \becatshare\hpc\> prompt OFF
smb: \becatshare\hpc\> mget temp
getting file \becatshare\hpc\temp\test_initramfs-2.6.32-504.23.4.el6.x86_64.img of size 20498182 as test_initramfs-2.6.32-504.23.4.el6.x86_64.img (14611.5 KiloBytes/sec) (average 14611.5 KiloBytes/sec)
smb: \becatshare\hpc\> recurse OFF
smb: \becatshare\hpc\> !ls
temp
smb: \becatshare\hpc\> !ls temp
test_initramfs-2.6.32-504.23.4.el6.x86_64.img
smb: \becatshare\hpc\> cd temp
smb: \becatshare\hpc\temp\> ls
  .                                   D        0  Thu Sep 10 14:09:22 2015
  ..                                  D        0  Thu Sep 10 14:09:22 2015
  test_initramfs-2.6.32-504.23.4.el6.x86_64.img      A 20498182  Thu Sep 10 14:09:22 2015

                65535 blocks of size 1073741824. 61536 blocks available
smb: \becatshare\hpc\> exit

The commands for the smbclient

?/help [command]
If command is specified, the ? command will display a brief informative message about the specified command. If no command is specified, a list of available commands will be displayed.
! [shell command]
If shell command is specified, the ! command will execute a shell locally and run the specified shell command. If no command is specified, a local shell will be run.
cd <directory name>
If "directory name" is specified, the current working directory on the server will be changed to the directory specified. This operation will fail if for any reason the specified directory is inaccessible.
If no "directory name" is specified, the current working directory on the server will be reported.
del/rm <mask>
The client will request that the server attempt to delete all files matching mask from the current working directory on the server.
dir/ls <mask>
A list of the files matching mask in the current working directory on the server will be retrieved from the server and displayed.
du <filename>
Does a directory listing and then prints out the current disk usage and free space on a share.
exit/quit
Terminate the connection with the server and exit from the program.
get <remote file name> [local file name]
Copy the file called remote file name from the server to the machine running the client. If specified, name the local copy local file name. Note that all transfers in smbclient are binary. See also the lowercase command.
history
Displays the command history.
lcd [directory name]
If directory name is specified, the current working directory on the local machine will be changed to the directory specified. This operation will fail if for any reason the specified directory is inaccessible.
If no <cdoe>directory name</code> is specified, the name of the current working directory on the local machine will be reported.
lowercase
Toggle lowercasing of filenames for the get and mget commands.
When lowercasing is toggled ON, local filenames are converted to lowercase when using the get and mget commands. This is often useful when copying (say) MSDOS files from a server, because lowercase filenames are the norm on UNIX systems.
mask <mask>
This command allows the user to set up a mask which will be used during recursive operation of the mget and mput commands.
The masks specified to the mget and mput commands act as filters for directories rather than files when recursion is toggled ON.
The mask specified with the mask command is necessary to filter files within those directories. For example, if the mask specified in an mget command is "source*" and the mask specified with the mask command is "*.c" and recursion is toggled ON, the mget command will retrieve all files matching "*.c" in all directories below and including all directories matching "source*" in the current working directory.
Note that the value for mask defaults to blank (equivalent to "*") and remains so until the mask command is used to change it. It retains the most recently specified value indefinitely. To avoid unexpected results it would be wise to change the value of mask back to "*" after using the mget or mput commands.
md/mkdir <directory name>
Create a new directory on the server (user access privileges permitting) with the specified name.
mget <mask>
Copy all files matching mask from the server to the machine running the client.
Note that mask is interpreted differently during recursive operation and non-recursive operation - refer to the recurse and mask commands for more information. Note that all transfers in smbclient are binary. See also the lowercase command.
mput <mask>
Copy all files matching mask in the current working directory on the local machine to the current working directory on the server.
Note that mask is interpreted differently during recursive operation and non-recursive operation - refer to the recurse and mask commands for more information. Note that all transfers in smbclient are binary.
prompt ON/OFF
Toggle prompting for filenames during operation of the mget and mput commands.
When toggled ON, the user will be prompted to confirm the transfer of each file during these commands. When toggled OFF, all specified files will be transferred without prompting.
put <local file name> [remote file name]
Copy the file called local file name from the machine running the client to the server. If specified, name the remote copy remote file name. Note that all transfers in smbclient are binary. See also the lowercase command.
rd/rmdir <directory name>
Remove the specified directory (user access privileges permitting) from the server.

Reference

More command information is available at Smbclient.