Using SambaRobert Eckstein, David Collier-Brown, Peter Kelly1st Edition November 1999 1-56592-449-5, Order Number: 4495 416 pages, $34.95 |
2.5 Starting the Samba Daemons
There are two Samba processes, smbd and nmbd, that need to be running for Samba to work correctly. There are three ways to start:
2.5.1 Starting the Daemons by Hand
If you're in a hurry, you can start the Samba daemons by hand. As root, simply enter the following commands:
#/usr/local/samba/bin/smbd -D
#/usr/local/samba/bin/nmbd -D
At this point, Samba will be running on your system and will be ready to accept connections.
2.5.2 Stand-alone Daemons
To run the Samba processes as stand-alone daemons, you need to add the commands listed in the previous section to your standard Unix startup scripts. This varies depending on whether you have a BSD-style Unix system or a System V Unix.
2.5.2.1 BSD Unix
WIth a BSD-style Unix, you need to append the following code to the rc.local file, which is typically found in the /etc or /etc/rc.d directories:
if [ -x /usr/local/samba/bin/smbd]; then echo "Starting smbd..." /usr/local/samba/bin/smbd -D echo "Starting nmbd..." /usr/local/samba/bin/nmbd -D fiThis code is very simple; it checks to see if the smbd file has execute permissions on it, and if it does, it starts up each of the Samba daemons on system boot.
2.5.2.2 System V Unix
With System V, things can get a little more complex. System V typically uses scripts to start and stop daemons on the system. Hence, you need to instruct Samba how to operate when it starts and when it stops. You can modify the contents of the /etc/rc.local directory and add something similar to the following program entitled smb:
#!/bin/sh # Contains the "killproc" function on Red Hat Linux ./etc/rc.d/init.d/functions PATH="/usr/local/samba/bin:$PATH" case $1 in 'start') echo "Starting smbd..." smbd -D echo "Starting nmbd..." nmbd -D ;; 'stop') echo "Stopping smbd and nmbd..." killproc smbd killproc nmbd rm -f /usr/local/samba/var/locks/smbd.pid rm -f /usr/local/samba/var/locks/nmbd.pid ;; *) echo "usage: smb {start|stop}" ;; esacWith this script, you can start and stop the SMB service with the following commands:
# /etc/rc.local/smb start Starting smbd... Starting nmbd... # /etc/rc.local/smb stop Stopping smbd and nmbd...2.5.3 Starting From Inetd
The inetd daemon is a Unix system's Internet "super daemon." It listens on TCP ports defined in /etc/services and executes the appropriate program for each port, which is defined in /etc/inetd.conf. The advantage of this scheme is that you can have a large number of daemons ready to answer queries, but they don't all have to be running. Instead, the inetd daemon listens in places of all the others. The penalty is a small overhead cost of creating a new daemon process, and the fact that you need to edit two files rather than one to set things up. This is handy if you have only one or two users or your machine has too many daemons already. It's also easier to perform an upgrade without disturbing an existing connection.
If you wish to start from inetd, first open /etc/services in your text editor. If you don't already have them defined, add the following two lines:
netbios-ssn 139/tcp netbios-ns 137/udpNext, edit /etc/inetd.conf. Look for the following two lines and add them if they don't exist. If you already have
smbd
andnmbd
lines in the file, edit them to point at the new smbd and nmbd you've installed. Your brand of Unix may use a slightly different syntax in this file; use the existing entries and the inetd.conf manual page as a guide:netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd netbios-ns dgram udp wait root /usr/local/samba/bin/nmbd nmbdFinally, kill any smbd or nmbd processes and send the inetd process a hangup (HUP) signal. (The inetd daemon rereads its configuration file on a HUP signal.) To do this, use the
ps
command to find its process ID, then signal it with the following command:#kill -HUP process_id
After that, Samba should be up and running.
© 1999, O'Reilly & Associates, Inc.