File Server Installation

Introduction:

In this tutorial we will be using Samba for the file sharing service. This is ideal if you wish to run a file sharing server in a Windows environment.

We will discuss the installation of samba as well as some basic configurations. We will also discuss modifying and creating user accounts. There will also be some suggested configurations for the client workstations and some more advanced samba configurations.

Installing Samba:

File sharing is a very important part of any server. Since most of the servers will be working with Windows machines as many of you are home users that are installing a FreeBSD server for web, mail, ftp, etc, you may want to consider setting up a file server. This is helpful if you are updating Web documents on the server and are tired of transferring that information evertime you want to test the changes. This will allow you to setup a shared directory and map a drive to the directory and edit the documents directly.

Install the Port

  1. The first thing you need to do is to install samba
    	# cd /usr/ports/net/samba
    	# make all install clean
    	
  2. Copy the samba.sh script and the smb.conf files:
    	# cp /usr/local/etc/rc.d/samba.sh.sample /usr/local/etc/rc.d/samba.sh
    	# cp /usr/local/etc/smb.conf.default /usr/local/etc/smb.conf
    	

At this point samba should be installed with no errors. Before starting the service you should do some basic configuration in order to get the samba service up and running which will be covered in the next article.
| 2 | 20020410152925 | 2 | 20020410152925 |
| 53 | 3 | 11 | Basic Samba Configuration |There is a lot of items that you can configure here. If you are interested running samba as a PDC for a windows network there is some support but at the time that this was written it was still fairly new and bugging. One of the recommendations that I can make is that you just use samba as your main server and don't not play with the PDC stuff. This does mean that you will have to update the samba password file when a user changes their local user password.

Below you will see a sample smb.conf file for basic setup and networking. Once you have it up and running make sure that you can see the internal shared drives and that you can attach to them. If you are successful with this continue and make login scripts if you think this would be appropriate.

Edit the smb.conf file

# vi /usr/local/etc/smb.conf

Sample Configuration File:


# Global Variables
[global]
workgroup = BSDSMB
server string = FreeBSD Samba Server
hosts allow = 192.168. 127. 148.231.64.212
max log size = 50
security = user
encrypt passwords = yes
socket options = TCP_NODELAY
dns proxy = no

# Shared Directories
[public]
comment = Public
path = /usr/net/public/
writeable = yes
printable = no
write list = adminuser

[home]
comment = Home Directory
path = /usr/net/home/%U
public = no
writeable = yes
create mask = 0700

[maildata]
comment = Maildata Folder
path = /usr/net/maildata/%U
public = no
writeable = yes

[apps]
comment = Apps Volume
path = /usr/net/apps
public = no
writeable = yes
write list = adminuser

[usr]
comment = Users Volume
path = /usr/home
valid users = adminuser
public = no
writeable = yes
printable = no

[web]
comment = Web Folder
path = /usr/local/www
valid users = adminuser
public = no
writeable = yes
printable = no
create mask = 0775

[backup]
comment = Backup Folder
path = /usr/net/backup
valid users = adminuser
public = no
writeable = yes
printable = no

Now samba should be installed and ready to start sharing files. There is another very important step before this will work. You need to create user accounts for access to the server. This will be covered in the next article along with some other basic samba commands.

Using the Samba Interface:

Samba has quite a few commands that are very helpful. We will be covering just some of the more basic commands that you will need to know

  1. To lookup a particular shared network use the following command

    # smbclient -l (server name) -n

    Example: smbclient -l bsd_samba -n
    bsd_samba is the name of the samba server

  2. To change/create a username and password you must use the following command

    # smbpasswd -a username

    Note: there are some other options for this command: see the man pages
    Note: you also have to have a user created on the system already

  3. You can also send commands to attach to other shared drives on Windows systems but there really shouldn't be a need for this if you are going to be running a pure file server.

Once you have your account setup and samba install you can start the service.

# /usr/local/etc/rc.d/samba.sh start

Login to your windows machine with the same account you created on the FreeBSD box in samba and view the network neighborhood for your samba server and shared drives.

The next article will cover some of the more common error messages.

Troubleshooting:

As with almost any system you are going to run into problems. We will attempt to list all the problems we have encountered here with the solutions.

  1. Error logging into whatever

    Make sure that you have setup a samba username and password for the account that you are trying to attach with

  2. Error connecting to server

    If you are trying to connect to a share on a W2K systems and get this error let me know because I haven't found a solution yet.

The next articles will cover some suggested client configurations and some of the more advanced samba configurations. | 2 | 20020506132902 | 2 | 20020410154226 |
| 72 | 5 | 11 | Connecting to Windows from FreeBSD |You may want to connect to Windows shares from your FreeBSD either to backup windows systems to tape, manage files, etc. In this tutorial we will discuss connecting to windows shares using Samba.

This tutorial assumes that you have a working share on a windows workstation within your local area network. If you need assitance in setting up a windows share please review the windows help on "File and Print Sharing".

There are two main options for connecting to a windows system from your FreeBSD server. The first option involves using the smbclient (similar to FTP) to connect to your windows share. The other option is using the smbfs file system to mount the file system as you would any others using mount_smbfs.

Using "smbclient"

The smbclient acts similar to an FTP account but using the file sharing user accounts and permissions configured on the windows server. You can do serveral tasks which should be enough for most uses. An example of "tar" is found below.

smbclient //server/share -U user

If you are unable to access the windows server it will prompt you for a password. Type in the correct password for the username you provided in the command line and if authenticated you will be given a smb:\> command prompt. If it can't connect you will be given some warnings and you will exit to the shell.

Note: You will need to have an account with read or read/write permissions to the corresponding share.

Sample tar commands from the smb:\> command prompt:

Backup the share to tape drive:
tar c /dev/tape_device

Backup to file:
tar c /usr/backup_path/backupfile.tar.gz

Backup share using a single command from the shell:
smbclient //server/share -U user -Tc backupfile.tar.gz

Restore a file to the SMB share from within smbclient:
tar x /dev/tape_device

Restore a file to the SMB share from within the shell:
smbclient //server/share -U user -Tx tar_file

Using smbfs

If you are using FreeBSD 4.5 the smbfs is already built in. If you are using a previous version of FreeBSD then you will need to install the port:
cd /usr/ports/net/smbfs
make all install clean

Before we can begin using the SMB share drive from the windows system we will need to mount it using the "mount_smbfs" command:
mount_smbfs //username@server/share_name /mnt/path

If the server name is not listed in your "etc/hosts" file you may need to use the following command instead:
mount_smbfs -I 192.168.20.20 //username@server/share_name /mnt/path

Note: If you receive an error regarding "missing cfg file" simply:
touch ~/.nsmbrc
If you receive an error: "mount_smbfs: can't get handle to requester (no /dev/net/nsmb* device)" You mostly likely upgraded to FreeBSD 4.5 and did not run mergemaster or did not update your /dev/MAKEDEV.

This is a static configuration file - see man mount_smbfs for more details

After you have successfully mounted the SMB share drive you may now use it as you would any other mounted drive. Including using tar for backups.

Another Alternative

You may also use Sharity-Light, previously known as Rumba. The following is a link containing a little more information on using Sharity-Light.

BSDToday.Com

Advanced Web based Configuration:

For those of you that would like to take advantage of a built in web interface to manage samba, swat is the tool that you will be using.

Swat is installed by default as part of the samba package and is extremely easy to get up and running. The first step is to backup your current samba configuration file.

# cp /usr/local/etc/smb.conf /usr/local/etc/smb.conf.orig

Now let's get swat up and running and start our online administration. In most cases the necessary files will already be modified with one minor exception. If you run into problems check out the man pages for swat for installation instructions.

# vi /etc/inetd.conf

Remove the comment beside the swat line (most likely at the end of the file.

Now let's restart the inetd service with swat support.

# kill -HUP `cat /var/run/inetd.pid`

Now load up your webrowser and connect to:

http://yourserver.com:901


Enter in with your administrator username and password and start modifying your samba configuration.

Users can also login to manage their own passwords if they decide to change them.