Categories
Apps & OS's Technology

Settings up a simple home file server on Ubuntu Server 10.04

As you can proberbly tell from my other blog posts I really do like Ubuntu although I also admire CentOS/Redhat but for sheer simplicity and non-bloat installation I do like this awesome distrubution.

Ok so nowadays more and more people have more than one PC or network device at home and therefore it would be benefical to setup a shared storage device (A home file server basically)… So this is what I’m going to run through…

Firstly let me say that this is a very basic file server that can be accessed from pretty much all operating systems… eg. Microsoft Windows, Linux, UNIX, MacOSX and even XBox’s etc….

In this tutorial we’ll setup a single shared folder on a Ubuntu Server, the shared folder will not require any username or password to access it (its a home network after all!) If you wanted to add more security or more advanced features to your File (and even Print) server check out this page from the Ubuntu Server Guide: https://help.ubuntu.com/10.04/serverguide/C/samba-fileprint-security.html

Lets begin…

If you don’t already have Ubuntu Server installed, grab the ISO from the Ubuntu website, burn it to a CD and then install it on an PC. (this is very easy indeed!)

Login to your newly installed server as the ‘root‘ user and now we will install samba as follows:-

apt-get install samba

Thats all there is to it really, so now we can get streight on with configuring Samba….

The main Samba configuration file is located in /etc/samba/smb.conf . The default configuration file has a significant amount of comments in order to document various configuration directives.

Firstly, edit the following key/value pairs in the [global] section of /etc/samba/smb.conf:

workgroup = EXAMPLE

security = user

The securityparameter is farther down in the [global] section, and is commented by default. Also, change EXAMPLE to better match your environment.

Create a new section at the bottom of the file, or uncomment one of the examples, for the directory to be shared:

[shared]
comment = Ubuntu File Server Share
path = /srv/samba/share
browsable = yes
guest ok = yes
read only = no
create mask = 0755

  • comment: a short description of the share. Adjust to fit your needs.
  • path: the path to the directory to share. This example uses /srv/samba/sharename,Technically Samba shares can be placed anywhere on the filesystem as long as the permissions are correct, but adhering to standards is recommended.
  • browsable: enables Windows clients to browse the shared directory using Windows Explorer.
  • guest ok: allows clients to connect to the share without supplying a password.
  • read only: determines if the share is read only or if write privileges are granted. Write privileges are allowed only when the value is no, as is seen in this example. If the value is yes, then access to the share is read only.
  • create mask: determines the permissions new files will have when created.

Now that Samba is configured, the directory needs to be created and the permissions changed. Enter the following:

sudo mkdir -p /srv/samba/share
sudo chown nobody.nogroup /srv/samba/share/

The -p switch tells mkdir to create the entire directory tree if it doesn’t exist. Change the share name to fit your environment.

Finally, restart the samba services to enable the new configuration:

/etc/init.d/samba restart

From a Windows client you should now be able to browse to the Ubuntu file server and see the shared directory. To check that everything is working try creating a directory from Windows.

To create additional shares simply create new [dir] sections in /etc/samba/smb.conf, and restart Samba. Just make sure that the directory you want to share actually exists and the permissions are correct.

I hope this helps, you make find the following links of interest if you want to further build on your new file server:-

  1. The Official Samba ‘Howto’ collection.
  2. The Ubuntu Samba Community Wiki page.