A bash script for WindowsDFS mount in Linux

Since the Kerberos Tickets only works for 24 hours in our system,
i wrote a bash script for crontab to automatically remount a windows DFS
directory in our linux system.

Please sieh my post: Mount Windows DFS in Linux with Kerberos

You should run this bash as “root” or root user. If you want to use it for other users,
your should check the rights for your users.

this script only need to be called once, even the kerberos tickets is invalid after
24hours the mount  point is still working. you still have write and read access
to the mounting point (Windows DFS Directory).
Just make sure after server reboot,
this script will be called.


#Editted in 10.05.2012
mountDIR=<your mount point in linux system>
mountingDIR=<your directory in windows DFS //windows/directory >
# AD User and AD password
ad_user=<your Active Directory user, who can be authenticated in AD>
ad_password=<AD user password>
# Access User for Mounting Directory in DFS
user=< User who has the access and write rights in Windows DFS directory, $ad_use >
password=< User password for DFS directory ,$ad_password >
# DFS Domain
dom=<Your DFS directory Domain, XXX >
# Access Richts Setting for Mount Point
uid=< The user who should have access from Linux to access the Mount Point, 
      your DFS after mounting >
gid=< The Group who should have access from Linux to access the Mount Point >

#creat mount point directory
if [ ! -d $mountDIR ]
        echo "Directory doesn't exist"
        mkdir $mountDIR       
        echo "Directory exist, it will be unmounted"
        /sbin/umount.cifs $mountDIR

# get kerbos granting ticket from AD, the user must be a memeber of AD
kinit $ad_user $ad_password;

# after the ticket successfully granted, mount nas Directory to mount point
# use uid and gid option to specify the user id and group id'
# for mount point access rights
/sbin/mount.cifs $mountingDIR $mountDIR -o user=$user,dom=$dom,

About yingding wang
i am looking forward to innovation in IT and Robotics

Comments are closed.

%d bloggers like this: