User Tools

Site Tools


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/ \\\users\david
/mnt/download \\\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
// /home/david/documents cifs auto,iocharset=utf8,uid=david,gid=david,credentials=/root/.cifscredentials-david,file_mode=0700,dir_mode=0700 0 2
// /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:


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)