Wednesday, October 29, 2008

HowTo: Using Fstab entries to mount Samba shares on Linux

Samba is an Open Source/Free Software suite that provides file and print services to all manner of SMB/CIFS clients. Samba is freely available, and allows for interoperability between Linux/Unix servers and Windows-based clients.

Samba shares can be accessed in several ways, such as issuing the mount command, using /etc/fstab entries, accessing it through file browsers such as Konqueror, Midnight Commander and Nautilus.

The current post addresses /etc/fstab entries on Linux systems.

To automatically mount a Samba share at boot time we need to edit the /etc/fstab file and add the necessary entry:
  • $ su
  • # vim /etc/fstab
// /mnt/samba smbfs username=username,password=yourpassword 0 0
Due to security issues it’s not a good idea to put username/password in the /etc/fstab file. So you can change the username=username,password=password section and replace it with credentials=/root/.fstabcredentials:
  • # vim /etc/fstab
// /mnt/samba smbfs credentials=/root/.fstabcredentials 0 0
Next we create the /root/.fstabcredentials file and add the needed information:
  • # vim /root/.fstabcredentials
Substitute the username and password arguments according to your system.

To further close access to the file we change it's permissions:
  • # chmod 600 /root/.fstabcredentials
And that's it!


No comments: