{"id":534,"date":"2015-03-07T23:57:13","date_gmt":"2015-03-07T23:57:13","guid":{"rendered":"http:\/\/www.tech-g.com\/?p=534"},"modified":"2024-10-18T04:18:45","modified_gmt":"2024-10-18T04:18:45","slug":"moving-files-in-linux-with-samba","status":"publish","type":"post","link":"https:\/\/www.voodoo.business\/blog\/2015\/03\/07\/moving-files-in-linux-with-samba\/","title":{"rendered":"Moving files in linux with samba"},"content":{"rendered":"\n<p>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<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>To mount we can simply execute the following<\/p>\n\n\n\n<p>1- Install the client tools to mount the folder<br>apt-get install cifs-utils<\/p>\n\n\n\n<p>then<br>mkdir \/hds<br>mkdir \/hds\/smbmount<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mount -t cifs \/\/192.168.15.116\/sharedfolder \/hds\/smbmount -o username=techg,noexec<\/pre>\n\n\n\n<p>That&#8217;s it, now use CP and MV as you would normally<\/p>\n\n\n\n<p>One problem i faced with this method before was that my WD My Book Live shares would not mount, it threw an error<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mount error(22): Invalid argument<br>Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)<\/pre>\n\n\n\n<p>The logs did not provide much help either<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">CIFS VFS: cifs_mount failed w\/return code = -22<\/pre>\n\n\n\n<p>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<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mount -t cifs \/\/192.168.2.116\/sharedfolder \/hds\/smbmount -o vers=2.0,username=techg,noexec<\/pre>\n\n\n\n<p>The values for Version can be 2.0 2.1 3.0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mounting samba shares at boot time<\/h2>\n\n\n\n<p>My NAS server is always online, I switch my PC off while I am asleep, yes, being green may be a factor I claim, but the truth is, my personal machine has spinning hard drives, and my backups are not always up to date, so if a disk fails while I am asleep, and ticks it&#8217;s way to its own demise, I would then remember that I should have been more green, Anyway, let us get to the mounting<\/p>\n\n\n\n<p>1- create the file \/home\/qworqs\/.smbcredentials and fill it up with the contents below<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">username=qworqs <br>password=qwarks<br>domain=<\/pre>\n\n\n\n<p>Now that we have our credentials stored somewhere, we can add the following line to our fstab file, yes, it makes no sense that I have a folder called \/hds that I mount all my disks and network shares to, but I have been doing this since I was young<\/p>\n\n\n\n<p>So, open the file <strong>\/etc\/fstab<\/strong> and add the following line<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/192.168.1.100\/sharename \/hds\/100share cifs credentials=\/home\/qworqs\/.smbcredentials,rw,uid=qworqs,gid=qworqs,noauto,nofail,x-systemd.automount,_netdev      0       0<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,138],"tags":[],"class_list":["post-534","post","type-post","status-publish","format-standard","hentry","category-linux","category-samba"],"_links":{"self":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/comments?post=534"}],"version-history":[{"count":11,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/534\/revisions"}],"predecessor-version":[{"id":4027,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/534\/revisions\/4027"}],"wp:attachment":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/media?parent=534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/categories?post=534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/tags?post=534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}