How to have a cifs (smb) share mount on startup with authentication

By | 3 August 2011

If you want to have a smb share mount on start up on a Linux system there are several options. I think the easiest option is to embed the auth info in a file only readable by root. All you have to do is put the auth file in the appropriate /etc/fstab mount line and it will work on boot. So, say we want to mount the default C$ share on a Windows box every time our Linux server boots. Here is what I would put in /etc/fstab:
//WINSRV/c$ /mnt/winsrv_c cifs credentials=/etc/credfile,domain=MYDOMAIN 0 0

My /etc/credfile file would contain two lines as follows:

Of course, WINUSER would be your domain (or local Windows) username and WINPASS would be you password. You want to set the permissions on this file to read/write for only root. As root (or sudo) you would run chmod 600 /etc/credfile.

Now you should be able to run ‘mount /mnt/winsrv_c’ at the command line to mount your windows c$ share. The mount will also show up again when you perform a reboot.

One thought on “How to have a cifs (smb) share mount on startup with authentication

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.