Mounting a samba share on boot?

Bill Tillman btillman99 at yahoo.com
Tue Dec 11 22:08:45 UTC 2012





________________________________
From: Polytropon <freebsd at edvax.de>
To: Hanafi Syahroini <hanafi at zigma-jp.com> 
Cc: freebsd-questions at freebsd.org 
Sent: Tuesday, December 11, 2012 11:57 AM
Subject: Re: Mounting a samba share on boot?

On Tue, 11 Dec 2012 23:25:56 +0700, Hanafi Syahroini wrote:
> [nothing]

First of all, it's not uncommon to place the question into
the message body (which you did not), and using a descriptive
subject (which you did). :-)

So I assume your question is _how_ to mount a SMB share at
boot.

This can be easily done by adding the required line to the
/etc/fstab file. Because network connection is required to
perform the mount, you could use the "late" option in
addition to other options you might need. See "man mount"
for detais, as well as /etc/rc.d/mountlate.

The line would be like this:

    //USERNAME at SERVERNAME/share  /smb/share  smbfs  rw,late  0  0

In this example, SERVERNAME is the server to access, and "share"
the name of the share; /smb/share will be the directory it will
be mounted at.

Access to multiple "drive letters" would look like this:

    //Administrator at WINPC/a$  /smb/a  smbfs  rw,late  0  0
    //Administrator at WINPC/c$  /smb/c  smbfs  rw,late  0  0
    //Administrator at WINPC/d$  /smb/d  smbfs  rw,late  0  0
    //Administrator at WINPC/e$  /smb/e  smbfs  rw,late  0  0
    //Administrator at WINPC/f$  /smb/f  smbfs  rw,late  0  0

Here "WINPC" is the name of the server. Using "Administrator"
in this case is not safe, but no problem in settings where
people don't care for security anyway. :-)

Also see "man smbfs" and "man fstab" for details.

It might be required to put additional information in
/etc/nsmb.conf, for example:

    [default]
    workgroup=YOUR_WORKGROUP_NAME

    [SERVERNAME]
    addr=192.168.2.2

    [SERVERNAME:USERNAME]
    password=TOPSECRET

Substitute SERVERNAME, USERNAME and TOPSECRET for the
organisational information and access credentials that apply.
See "man nsmb.conf" for details.

Further instructions can easily be found in the online docs:

http://www.freebsd.org/doc/faq/book.html#mount-smb-share

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-samba.html



Note that if you still encounter network problems, it's better
to write a short rc.d style script that performs the mount_smb
commands, and use the proper keywords to have it run when the
network connection is up and running. See "man rc.d" for
details.


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
freebsd-questions at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


That's a great answer but let me insert that most people, not all but most, do not use Samba to access a server from other FreeBSD servers. So I feel the two replies thus far are overkill. Typically, Samba is used so that Windows or other SMB type OS'es can access the server. That said, I would simplify all this with the way I have mine setup. You will of course need the shares configured in your smb.conf, then simply put a command in your /etc/rc.local or /etc/rc.d/ to launch smdb and nmbd. I don't rely on anything in /etc/fstab to use samba. It's all in my smb.conf file.

However, Polytropon has presented a great answer here.


More information about the freebsd-questions mailing list