One of the main reasons I wanted a dedicated home server is to use it as a backup and file server. I work on a laptop and a desktop and keeping all my data in sync, accessible and backed-up for me is the biggest challenge of working on multiple machines. I used to play around with burning DVD's and copying files to external USB drives but I got fed up with it and tried to tackle that problem.
File server
I've heard a lot about Samba but I know only the basics. As I understand, it is a software package that can be used to share directories over the network and act as a print server between Microsoft Windows systems and Unix-like systems. So Samba will let me setup network shares for chosen directories on the server. These shares can appear to a Microsoft Windows system as normal Windows folders accessible via the network. On my Linux box I can also just mount those shares to become part of the file system. Perfect.
Note that this configuration was done on Ubuntu Server 8.04.1
First get the Samba software from your local apt mirror:
First get the Samba software from your local apt mirror:
sudo apt-get install samba
After installation and before you start messing around, make a copy of the Samba configuration file:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.original
Next, I will try to explain how I configured my Samba setup. Mind you I'm no expert at all in this matter, but I managed to get a configuration working that suits my needs.
The way I wanted it to work is: giving logged in Windows users access to shared resources on the server. Using the same username and password combination on the Windows machine as on the server. Authentication to the shared drives is handled in the background automatically based on the currently logged in Windows user that is accessing the shared resource.
On the XSERVER, which is my server's host name, I created a directory called "data", this is the root path for all data I want to store on the server, through Samba.
Make sure that the directories are owned by the "users" group. You can change the group of a directory with the following command:
sudo chgrp users /data
Under data, I created directories to organize the data by type like PICTURES, DOCUMENTS, MUSIC, etc...
Fire up your editor (I prefer nano) to change the Samba configuration file:
sudo nano /etc/samba/smb.conf
In the minimal Samba configuration below, you see values for the workgroup, machine name, user based security settings, ... I put this configuration together using the documentation that is provided on the Samba website.
In my configuration you can see 2 shares, pictures and documents. 2 Users (jkl and sara) are allowed to access these shares.
The mask directives determine the local file permissions for any new files or directories that are created in any of the shares.
[global] workgroup = MATRIX netbios name = XSERVER server string = Samba Server %v log file = /var/log/samba/log.%m max log size = 1000 socket options = TCP_NODELAY IPTOS_LOWDELAY preferred master = No local master = No dns proxy = No security = User [pictures] path = /data/PICTURES valid users = jkl, sara browsable = yes read only = no create mask = 0775 directory mask = 0775 [documents] path = /data/DOCUMENTS valid users = jkl, sara browsable = yes read only = no create mask = 0775 directory mask = 0775
Now all that remains on the Samba server is creating the user accounts that will access the Samba shares from Windows clients. I configured exactly the same username/password combinations on the Samba server as used on the Windows clients.
Create the "sara" user in Linux:
sudo useradd -c "Sara" sara
Add the new user to the "users" group:
sudo usermod -a -G users sara
Add samba user and samba password to the local Samba password file:
sudo smbpasswd -L -a sara
Enable the user:
sudo smbpasswd -L -e sara
Finally after all configuration is done, restart the Samba server to enable the configuration changes:
sudo /etc/init.d/samba restart
Now on your Windows client machine (I use Windows XP), in order to use load the Samba network shares as a driveletter you can issue the following command:
net use X: \\XSERVER\documents net use Y: \\XSERVER\pictures
After executing these commands and if the username/password combination of your Windows client match the Samba server's users, you can use the X and Y drive on your Windows client to store your precious data.
Conclusion
After a few hours of trial and error, the Samba setup was completed. This was my first Samba setup, so I'm happy to hear from anybody what I could have done better. But keep in mind all I want is a simple home setup, no highly secured over the internet corporate network storage stuff. For the moment, I'm very happy with my current configuration.
Over the gigabit network at home, I have no noticeable delays in handling and editing documents. Sometimes there is a small delay when flipping through a directory of 5 MB JPG images from the digital camera, but not so much that it becomes an issue for me.
When copying large file over the network to the Samba server (digital camera movies for example), the transfer can reach speeds of upto 70 MB/second. That is definitely fast enough to copy multi gigabyte files around.
No comments:
Post a Comment