Using fstab to automatically mount samba drives

It is possible to specify mount_smbfs-mounts in /etc/fstab. For instance it can be used to automatically mount Samba drives automatically at boot up. When I configured this I ran into a number of small problems. To not be needed to enter a password each time one can use /etc/nsmb.conf. Though I could not really get it to work, every time I got queried about the password even if I had given it in nsmb.conf. I tried both with unencrypted and crypted password. Nothing worked. By coincidense I tired to change the user name to only capital letters, and that solved it!

So in you nsmb.conf it should look like this:
[YELLOWORB:JOHN]
password=$$342342425435453

PS. Still have the noauto option and a mount script eventhough I have read it should work without noauto, though I had problems with it before and also it makes your system very dependent on the other machine with the samba drives. If that is not up and running if when you FreeBSD machine boots, the mounting will fail and the boot process will halt and your system will not go up.

Update 2007-05-24:
Yesterday I discovered after a reboot that my shares from a Windows machine wasnt mounted any more. I tried to use mount_smbfs manually but failed. It reported:
mount_smbfs: can't get server address: syserr = Permission denied

I spent quite some time searching for a solution and finally after posting on a mailinglist I figured it out. I’t nothing to do wiht permissions, Samba cannot locate the server, thats the problem! So if you specify its real address and not only WINS name it works:
mount_smbfs -I 192.168.0.2 //joe@FILESERVER/share /mnt

But how to solve it for fstab?
Again comes nsmb.conf into play. Under the each server section in nsmb.conf one parameter you can give is the address to the machine. Either the ip number or its realy networkname works, e.g. fileserver.mynetwork.com.

2 thoughts on “Using fstab to automatically mount samba drives

  1. Hello mate,
    I had the same problem in the past.
    I found many many suggestion all over the web but nothing consistent.
    So, after a lot of tries I finally got it working fine.
    The main tips i give to you are:
    1 – use capital letters on the nsmb.conf to specify the server and user on the section names
    2 – make sure it works only typing the mount_smbfs -N command
    3 – use simple configuration on fstab:
    eg. //user@server/share /mtpoint rw,-N

Leave a Reply

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