This tutorial shows you how to automatically mount users' home directories on login in Ubuntu when the shares to mount are in a DFS namespace.
Before you proceed, make sure you have joined the Ubuntu workstation to Windows domain and configured WINS client by following this tutorial. DFS uses WINS by default so you need WINS feature installed in some server.
First you need to install the following packages:
sudo apt-get install libpam-mount cifs-utils keyutils
In /etc/security/pam_mount.conf.xml
add a volume
tag for each share you want to mount for users automatically:
<volume user="*" sgrp="residents" fstype="cifs" server="your.domain.com" path="data/users/%(USER)/documents" mountpoint="~/Documents" options="uid=%(USER),gid=100,dir_mode=0700"> </volume>
The parameters above are:
- user: Limit the volume for specific users only. Wildcard (*) mounts the volume for all users, if no other filters are applied.
- sgrp: Limit the volume to users which are a member of the group identified by name. In my domain environment, all regular users are in a group called
residents
. - fstype: The filesystem type. Use
cifs
here to mount NTFS shares. - server and path: Here goes the full DFS path. If users' documents are in
\\your.domain.com\Data\Users\%username%\Documents
, put\\your.domain.com
inserver
anddata/users/%(USER)/documents
inpath
. See the manpage link below to find a list of other variables. - mountpoint: This is where the share is mounted.
- options: Here you can define some extra options. For example
dir_more
sets the permissions ofmountpoint
.
You can find more information about the config file in the manpage.
Edit or add the following line in /etc/pam.d/common-session
:
session optional pam_mount.so
Edit or add tge following line in /etc/pam.d/common-auth
:
auth optional pam_mount.so
Now when users log in, their documents have been automatically mounted in ~/Documents
.