How to Sharing Folder between Windows and CentOS

You may want to use a Linux server to back up Windows files Or vice versa. This can be made easy by mounting Windows shares on the server. You will be accessing Windows files as if they are local and essentially all Linux commands can be used.

This is useful for accessing remote directories from any system connected over same network. You can also mount these remote share on your Linux systems and use them as local file system. This tutorial will help you do mount remote windows share directories on Linux system using command line.

 

In this tutorial, you can easily establish this connection without using Samba. And you can easily transfer the files you want.

 

Step 1: install Requirement Packages

Mounting Windows (or other samba) shares is done through the cifs virtual file system client (cifs vfs) implemented in kernel.

for install cifs tools :

yum install cifs-utils

 

Step 2: Sharing Folder on Windows (or Cloud HDD)

  1. Choose Folder For Sharing.
  2. Right Click on the Folder, then Select Properties.
  3. on The Sharing Tab, Click Advanced Sharing.
  4. in Opened window, ticked “Share This Folder” Option.
  5. click Ok, Next Close.

 

Step 3: Mounting Windows Shared Folder to Centos

For This job, you first make a directory in /mnt Folder.

cd /mnt
mkdir folder_shared_name

Then you need Mounting Windows shared Folder to created directory.

mount -t cifs -o username=user,password=pass,dir_mode=0755,file_mode=0755 //windows.ip.address/shared_folder /mnt/folder_shared_name

 

Step 4: Copy All Files you need with Progress

You can use rsync instead of a regular copy on CentOS to get the percentage of the files being copied and to know the status of your files.

yum install rsync
rsync -arv --progress source destination

Tip: Using rsync  with progress makes it easy to copy large files. rsync also has the ability to copy folders and subfolders & files. Using the Centos CronTab, you can setup a auto backup system for your server.

 

Finally, after you finish your work, you can disconnect this connection.

umount /mnt/folder_shared_name

All done !!!