by Noah Gift
A huge problem in most digital households is a growing collection of data without an easy way to share it and store it in one spot. Music. Movies. Pictures. Documents, backups, operating system images. Wow! Where do you put all of this stuff?
You’re in luck, because it is quite simple to setup a Network Attached Storage (NAS) device that any operating system can mount and write to on the network. By using Samba, you can turn a Fedora server into a common shared storage medium for Mac OS X, Linux®, and Microsoft® Windows®. And it gets even better. With the lower cost of disk drives, it is quite possible to setup a 1-2 TB disk array as your Samba storage pool. How about that for a movie depot?!
If you’re a home user, you might only care about .001% of the configuration options of Samba. Basically, you would like a volume to mount on all of the computers in your house, and you would like to use it for file sharing. This share should only be accessible to a computer on your network. For home network security, you really only need an IP restricted share without authentication. Fortunately, this is one of the easiest possible configurations.
Keep in mind that this assumes you’re behind a firewall, although we will still be restricting the share to the local network. As a rule, all home networking should be done on a private network behind your firewall. The reason is simple; everyone makes mistakes and you may be in a hurry someday and skip a step and allow the whole world access to your home network.
With the security concerns behind us, let’s get to work.
Configuring Samba can be daunting, but it doesn’t have to be. Ignore the default configuration file and start over from scratch. The trick to configuring Samba quickly is to use only the configuration options you really need. But first, let’s set up an account for all of your Samba users, create a “sharepoint,” and give it proper permissions.
Preparing your server for SMB hosting
1. Create an account just for your SMB user.
As root, issue the following commands:
(This is up to you. Give the account a secure password. Number and special characters are always a good combination.)
2. Create a share folder.
3. Change permissions on the share.
chown -R fileserver901:fileserver901 /sharepoint
Setting up and configuring smb
Next we are going to set up and configure Samba to share out the directory we just set up and force all anonymous users to become the user
fileserver901. It is important to note that the underlying Linux file permission structure must belong to our user, fileserver901.
1. Check to see if samba is installed.
rpm -q samba
You should get something back like:
If not, you need to install Samba:
yum install samba
2. Make a backup of your current samba configuration file.
cp /etc/samba/smb.conf /etc/samba/smb.conf.original
3. Delete everything in the file and paste in the below sample config file.
You can accomplish this by using your favorite text editor like vim or emacs:
(note the only item to change will be your subnet value in the hosts allow line)
[global] workgroup = home netbios name = fedora security = share hosts allow = 192.168.0.0/24 [share] comment = Home File Server path = /sharepoint force user = fileserver901 force group = fileserver901 guest ok = yes read only = no
4. Test the syntax of the
Make sure you have your configuration correct:
You should see something similar to:
"Loaded services file OK."
5. Start the smb service and tell it to run on boot.
chkconfig smb on service smb start
Congrats, smb is now working!
Let’s quickly analyze the configuration file step by step:
[global] (signifies security parameters)
workgroup = home (names a windows workgroup name)
netbios name = fedora (our netbios name)
security = share (takes on permissions from the share, which we set earlier)
hosts allow = 192.168.0.0/24 (only allows this subnet to connect i.e. 192.168.0.119126.96.36.199)
[share] (Signifies the name of our share when mounted. You can change to anything you like.)
comment = Home File Server (creates share point comments)
path = /sharepoint (The full path the volume you want to share. Note if you want to share more than one volume, copy the “share” section and alter accordingly.)
force user = fileserver901 (forces all users of this mount to become this user and obtain access to whatever this user has access to)
force group = fileserver901 (forces all users of this mount to become this group and obtain access to whatever this group has access to)
guest ok = yes (allows anonymous accounts to access, which is how we can connect without a password)
read only = no (allows us to write to the volume. If you set this to yes, you could make this an anonymous “read” only volume)
Connect from Linux, Mac, and Windows
This is the fun part. Now that we have our server running, we should be able to mount this volume from any operating system that supports SMB, which is most. I will show you how to mount our volume on Linux, Mac OS X, and Windows 2003 Server.
Mac OS X Tiger
- Go to the Finder menu and select “Connect to Server” or press Apple key + “k”.
- In the server address bar, type in
smb://192.168.0.101(or whatever the address is of your home smb server).
- Select connect. When the dialog box appears, click on “Ok” for the “share.”
- A dialog box will appear with a workgroup, name, and password. Just ignore it and press ok again.
- A volume named share will appear on your desktop.
Windows 2003 Server
(Note: this should be almost identical for most other Windows versions.)
- Open the Windows Explorer.
- Type in:
\\192.168.0.101\share(or whatever the address is of your home smb server).
- You now have read/write access to the volume.
Red Hat® Enterprise Linux 5
(Note: this should be identical for any newer Gnome installation.)
- Go to Places and select “Connect to Server.”
- Under Service Type, select “Windows Share.”
- In the server address box, type in
192.168.0.101(or whatever the address is of your home smb server).
- In the share box, type
- A volume named share will appear on your desktop.
Getting cross platform file sharing working with Samba can be incredibly complicated, unless you focus on just the components of Samba you need. Most of Linux is like a swiss army knife, it can do just about anything. The trick to mastering Linux is to have the ability to ignore 99% of the options and to focus on the task at hand. We wanted to set up cross-platform file sharing via smb, not set up a Samba Domain Controller. The next step for the home user is to ponder how big of a NAS to set up. If you plan ahead, you could buy several large disks and stripe them together for redundancy and speed, and store all of your music and videos on it. The possibilities are endless.