Moving files in linux with samba

Well, we all know FTP, HTTP and other protocols would do the trick, but they are not the fastest way. because of setup and other considerations, especially when we are planing to use both windows and linux in the transactions, a low overhead method would be samba, or windows network file sharing

In windows, it is simple, we all know how to share a folder, and we all know how to open a shared folder over the network, in linux it is just as simple.

The detailed explanation of how to setup the samba server and share a folder is already in a post, but from the client side, you can copy a file by simply mounting the shared drive onto the linux server and copy or move files like you would a normal file or folder.

To mount we can simply execute the following

1- Install the client tools to mount the folder
apt-get install cifs-utils

then
mkdir /hds
mkdir /hds/smbmount

mount -t cifs //192.168.15.116/sharedfolder /hds/smbmount -o username=techg,noexec

That’s it, now use CP and MV as you would normally

One problem i faced with this method before was that my WD My Book Live shares would not mount, it threw an error

mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

The logs did not provide much help either

CIFS VFS: cifs_mount failed w/return code = -22

Turns out that the WD MyBook Live has an older version of Debian, and samba on that device had a max-v of 2, so the solution is to connect while specifying which version of samba works

mount -t cifs //192.168.2.116/sharedfolder /hds/smbmount -o vers=2.0,username=techg,noexec

The values for Version can be 2.0 2.1 3.0

Leave a Reply

Your email address will not be published. Required fields are marked *