Automating Mounting with Linux Samba Clients



Automating Mounting with Linux Samba Clients

You can also automate the mounting of shares by placing entries in your /etc/fstab file. In the example below the home directory of user peter on server 192.168.1.100 will be mounted on the /mnt/smb mount point as a Samba filesystem (smbfs) using the login information in the file named /etc/cred.

     #
     # File: /etc/fstab
     #
     //192.168.1.100/peter    /mnt/smb    smbfs    credentials=/etc/cred 0 0

The contents of the /etc/cred file needs to have the username and password for the account in this format

     #
     # File: /etc/cred
     #
     username = peter
     password = peterspassword

Once finished, you can use mount -a to mount the new /etc/fstab entry, and the /mnt/smb directory will contain the contents of the share.

     [root@smallfry tmp]# mount -a
     [root@smallfry tmp]# ls /mnt/smb
     backups profile   docs data music
     [root@smallfry tmp]#