Mounting a samba share on boot?

1 view
Skip to first unread message

Hanafi Syahroini

unread,
Dec 11, 2012, 11:25:56 AM12/11/12
to freebsd-...@freebsd.org

_______________________________________________
freebsd-...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questi...@freebsd.org"

Tim Daneliuk

unread,
Dec 11, 2012, 11:43:48 AM12/11/12
to freebsd-...@freebsd.org
On 12/11/2012 10:25 AM, Hanafi Syahroini wrote:

This can be done with appropriate entries in /etc/fstab. However,
I'd recommend against doing so because, if the SMB server
is unreachable when the FreeBSD system boots, the FreeBSD
box will hang looking for the SMB connection.

A better way is to put a custom script in /usr/local/etc/rc.d/
that initiates the SMB mounts there. This too could fail, but
it doesn't prevent the OS From booting fully.

--
-----------------------------------------------------------------------
Tim Daneliuk

Polytropon

unread,
Dec 11, 2012, 11:57:59 AM12/11/12
to Hanafi Syahroini, freebsd-...@freebsd.org
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@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@WINPC/a$ /smb/a smbfs rw,late 0 0
//Administrator@WINPC/c$ /smb/c smbfs rw,late 0 0
//Administrator@WINPC/d$ /smb/d smbfs rw,late 0 0
//Administrator@WINPC/e$ /smb/e smbfs rw,late 0 0
//Administrator@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, ...

Bill Tillman

unread,
Dec 11, 2012, 5:08:38 PM12/11/12
to freebsd-...@freebsd.org




________________________________
From: Polytropon <fre...@edvax.de>
To: Hanafi Syahroini <han...@zigma-jp.com>
Cc: freebsd-...@freebsd.org
Sent: Tuesday, December 11, 2012 11:57 AM
Subject: Re: Mounting a samba share on boot?
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.

Polytropon

unread,
Dec 12, 2012, 12:40:53 AM12/12/12
to Bill Tillman, freebsd-...@freebsd.org
On Tue, 11 Dec 2012 14:08:38 -0800 (PST), Bill Tillman wrote:
> 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.

Yes, that would be "the other way round", which I thought would
be less probable due to the question presented in the subject.
Terms like "mount [...] on boot" suggests that FreeBSD would act
as a SMB client here. Of course, the standard way to do things
like this would usually be something like NFS, which is not
very well supported in "Windows" land (and therefor requiring
SMB stuff).

Delegating the configuration into _one_ file (instead of spreading
it across /etc/fstab, /etc/nsmb.conf and maybe some handcrafted
/usr/local/etc/rc.d script) sounds like a much better approach.

Bill Tillman

unread,
Dec 12, 2012, 7:27:31 AM12/12/12
to freebsd-...@freebsd.org



________________________________
From: Polytropon <fre...@edvax.de>
To: Bill Tillman <btill...@yahoo.com>
Cc: "freebsd-...@freebsd.org" <freebsd-...@freebsd.org>
Sent: Wednesday, December 12, 2012 12:40 AM
Subject: Re: Mounting a samba share on boot?


I've heard from more than one person that Samba is no good. Including the IT
guru here where I work. All I know is that  I've been running it for years and
without a single incident. I quietly and reliably allows my Windows workstations
to access my FreeBSD server's like they were very expensive Windows file
servers. Never messed with the printing side of it and don't need to . File
sharing alone has been worth the investment in time to learn Samba.

As for NFS, I have found, on my network at least that using the TCP and -i
options to keep it from timing out has worked fine.

Jerry

unread,
Dec 12, 2012, 6:02:07 PM12/12/12
to FreeBSD
On Wed, 12 Dec 2012 04:27:31 -0800 (PST)
Bill Tillman articulated:

> On Tue, 11 Dec 2012 14:08:38 -0800 (PST), Bill Tillman wrote:
> > 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.
>
> Yes, that would be "the other way round", which I thought would
> be less probable due to the question presented in the subject.
> Terms like "mount [...] on boot" suggests that FreeBSD would act
> as a SMB client here. Of course, the standard way to do things
> like this would usually be something like NFS, which is not
> very well supported in "Windows" land (and therefor requiring
> SMB stuff).
>
> Delegating the configuration into _one_ file (instead of spreading
> it across /etc/fstab, /etc/nsmb.conf and maybe some handcrafted
> /usr/local/etc/rc.d script) sounds like a much better approach.

NFS is available on Windows 7, it's just not installed by default.

In order to activate the Client for NFS, go into the Control Panel, and
go to "Programs and Features". In the left hand column, you'll see a
link for "Turn Windows features on or off".

Select that, and it will open a list box that shows all of the optional
components built in to Windows 7. Some are already activated. Expand
the entry for "Services for NFS". There are two check boxes under
that. Check them and hit OK. Windows will install those components
and ask to reboot your system. Once you have rebooted, Client for NFS
will be installed.

To use it, go to Administrative Tools->Services for NFS to configure
it. Alternatively, you can use the command line program 'nfsadmin' to
configure.

For other versions of Windows, see: How to install Client for NFS on
Windows: <http://support.microsoft.com/kb/324055>

I have seen several setups with this sort of integration that worked
just fine.

--
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__________________________________________________________________

Reply all
Reply to author
Forward
0 new messages