Friday 2 November 2012

Mounting Samba / CIFS file systems in CentOS 5.6

10.50am. Mounting remote smb/cifs filesystems can be a little tricky due to the slashes required to complete the task.

From the command line:
mkdir /mnt/MOUNTPOINT (if you have not already done so)

mount -t cifs "//SERVERNAME/SHARE" /mnt/MOUNTPOINT/ -o username=DOMAINNAME\\USERNAME,password=PASSWORD
NB: the text in capitals will need to be substituted for your own scenario. Also note that there are two backward slashes between DOMAINNAME and USERNAME. This is by design as the cli will cancel out just one.

Once successful you may want to have this file system automatically mounted on boot. This can be achieved by modifying the /etc/fstab.

Insert into /etc/fstab:
//SERVERNAME/SHARE /mnt/MOUNTPOINT/ cifs username=DOMAIN\USERNAME,password=PASSWORD
NB: Again the text in capitals will need to be substituted for your own requirements. This time we only require one backslash between DOMAINNAME and USERNAME.

Once the fstab has been modified it is good practice to test that is performs as required, we can do that by performing the following:
umount /mnt/MOUNTPOINT (may still be mounted from testing earlier).
mount -a
Any errors will display on the command line, the mount can also be tested by getting a directory listing.

1 comment:

  1. Bear in mind that the fstab is world readable so you'd only want to do this on systems where you can trust the users.

    ReplyDelete