User Tools

Site Tools


access_windows_shares

Mount Windows file shares from Linux

I run Windows Home Server (WHS) on my home network. It holds shared folders for user documents but also pictures, common downloads etc. Only natural that I need access to some of those shares from my Linux environment. Samba FS and CIFS to the rescue:

Install CIFS:

sudo apt-get install cifs-utils

In my case, I wanted to connect WHS shares with my local user documents and a common download folder (where I e.g. keep the ISOs for Linux):

mount point remote share
~/documents/ \\192.168.1.100\users\david
/mnt/download \\192.168.1.100\download

Create the mount points:

sudo mkdir /mnt/download
mdkir ~/documents

Add entries to fstab:

sudo gedit /etc/fstab

Add mount entry lines like the following (this is formatted as a table for easier reading, but each table row obviously needs to be entered as a single line in /etc/fstab):

file system mount point type options dump pass
//192.168.1.100/users/david /home/david/documents cifs auto,iocharset=utf8,uid=david,gid=david,credentials=/root/.cifscredentials-david,file_mode=0700,dir_mode=0700 0 2
//192.168.1.100/download /mnt/download cifs auto,iocharset=utf8,uid=david,gid=users,credentials=/root/.cifscredentials-david,file_mode=0775,dir_mode=0775 0 2

Couple of things to note:

  • I'm assuming the ~/documents folder does not exist in your distro or is actually empty. Otherwise, once you mount the share, any local files will disappear
  • the per-user documents mount point has a more rigid file/directory mode to only allow the actual user access to those files (0700 to only set the user mode, but denies access from group or others)
  • the network credentials to access the windows share are not directly entered to /etc/fstab (this file is readable by everyone) but instead is in a separate credentials file in the root user's folder.
  • the uid/gid are local IDs that are associated as file/group owners to files from the windows share

Cache WHS user credentials:

sudo gedit /root/.cifscredentials-david enter 2 lines with the proper user/password that is recognized by the WHS:

username=someUser
password=a_password

Make this file only visible to root:

sudo chmod 0600 /root/.cifscredentials-david

Try out that the mounts work:

sudo mount /home/david/documents
sudo mount /mnt/download
access_windows_shares.txt · Last modified: 2014/11/01 14:13 (external edit)