How to Mount a Windows Shared Directory on a Linux System

Jun 26, 2019 0 comments


1) You can mount a Windows Share to a Linux system by using the following command:

 mount -t cifs //Remote_System_Name/Shared_Folder_Name /mnt/Remote_System_Name/Shared_Folder_Name -o username=MyUsername

  OR

 mount //Remote_System_Name/Shared_Folder_Name /mnt/Remote_System_Name/Shared_Folder_Name -o username=MyUsername

2) Once the Windows share is mounted, you can then copy the files to the Linux box using the following command:

 cp -a /source/. /dest/

3) After you copy the files over to the Linux box, you can unmount the filesystem using the following command:

 umount /dev/sdb

4) If you would like to mount a filesystem on system boot, you need to edit the /etc/fstab file. You also need to provide a credentials file which you will need to create. Follow the steps below to automount a Window Share at boot:

 4a) Create a credentials file somewhere in your user directory. Example /home/grayos/.smb
  touch /home/MyUsername/.smb

 4b) Edit the .smb file using your favorite text editor
  vim /home/MyUsername/.smb

 4c) Enter the following entries to your .smb file
  user=MyUsername
  password=MySecretPassword
  domain=MyDomainName

 4d) After you have created your credentials file, you will need to edit /etc/fstab to connect to the Windows share on Linux boot.

 4e) Edit /etc/fstab using your favorite text editor
  vim /etc/fstab

 4f) Append the following line to the end of /etc/fstab. Change /dev/sdb with your disk name.
  # for Windows Server 2008 samba shares:
  //Remote_System_Name/Shared_FolderName / /mnt/Remote_System_Name/SharedFolderName cifs uid=0,credentials=/home/MyUserName/.smb,iocharset=utf8,noperm 0 0

OR

  # for Windows Server 2016 samba shares:
  //Remote_System_Name/Shared_FolderName / /mnt/Remote_System_Name/SharedFolderName cifs uid=0,credentials=/home/MyUserName/.smb,iocharset=utf8,vers=3.0,noperm 0 0

 4g) If you would like to mount all of the filesystems in /etc/fstab now, run the following:
  mount -a

 4g) You can also unmount all of the drives in /etc/fstab using the following:
  umount –a

Comments

Related Posts

{{posts[0].title}}

{{posts[0].date}} {{posts[0].commentsNum}} {{messages_comments}}

{{posts[1].title}}

{{posts[1].date}} {{posts[1].commentsNum}} {{messages_comments}}

{{posts[2].title}}

{{posts[2].date}} {{posts[2].commentsNum}} {{messages_comments}}

{{posts[3].title}}

{{posts[3].date}} {{posts[3].commentsNum}} {{messages_comments}}

Search This Blog