Setup a Home Server
by Sanjeeva Wijeyesakere
First, a word of warning:
Please read through this entire article before attempting any installation of software. Also note that any installations you undertake are at your own risk and you should ensure that you have thoroughly read and understood the manufacturer's instructions and caveats for each software package you install. Furthermore, if you want to operate a publicly accessible server, you should check with your internet service provider (ISP) if this violates the terms of your service contract.
Part I: Getting Started
Before you start reading this article, you may be wondering why you would ever need a home server. What are the benefits of having a home server and why should you build your own? The simple answer to this question is that a home server provides you with the same benefit that servers provide businesses and commercial organizations. It allows you to have a central location for you to store files and provides for an easy backup option as well as the ability to share and synchronize files and calendars across multiple computers in your home.
The second benefit of having a home server is that it allows you to recycle an old PC, thereby putting it to good use instead of relegating it to be a paperweight. In addition to this, having a home server allows you to host your own website and have remote access to your files when you are away from home. It is very important that you check your internet service provider’s (ISP’s) terms and conditions of service since running a publicly accessible server may violate your service contract with your ISP and could have serious repercussions.
If you decide to setup your own server, your first hurdle is to make sure your system's hardware is appropriate for its intended purpose. The most important piece of hardware is a functioning network interface card (NIC). A file server used for backups needs a large hard drive, so you need to make sure you have plenty of disk storage available. You should also make sure that your system has sufficient memory (RAM) for the software (operating system, etc.) you will be running. As a (very) rough guide, an old x86 system with 128 MB - 1 GB of RAM should suffice for a headless Linux server while 512 MB - 4 GB of RAM would suffice for a Windows or OS X server.
Now, you should consider what operating system (OS) you wish to use. If you want a system for backing up files from within your home network, any version of Windows 98 or above would suffice. You would simply share a folder across your network to copy files to and from your server. However, such a setup would pose some serious security issues (if you are running an older version of Windows that is no longer supported), have high system requirements and could be rather expensive (a full-install copy of Windows XP home can cost approximately $200 and a full-install copy of Windows XP professional can cost $300). The main advantage with using Windows is its ease of use and its wide range of supported hardware.
Similarly, if you have an old Macintosh running OS X (which is a based on BSD), you can turn it into a file and Web server by enabling these services in the relevant OS X preference pane (OS X includes Samba and Apache). However, unlike Windows, a new license for the latest version of OS X Sever is relatively cheap, but tends to come with some steep hardware requirements. As with Windows, the ease of use of OS X is its main advantage.
However, if you want a powerful, open-source alternative to Windows and OS X, Linux provides an ideal solution for your home server's OS. The main disadvantage to using Linux is that it takes a little time to setup and configure. However, once configured, your Linux system will be a fully functioning, robust and reliable server.
If you choose to go with Linux, you need to decide what distribution to use. There are many distributions (or 'distros') of Linux, each of which has its own unique set of features and hardware support. My personal preference is for distributions of Linux based on Debian since I like the Debian package manager as it allows for easy installation of applications using the Debian package manager. Currently, my favorite Linux distribution is Linux Mint, which is based on the popular Ubuntu distro. Ubuntu-based distros tend to have extensive support for a wide variety of hardware and is easy to setup and configure. You can download a free ISO images of the Linux Mint and Ubuntu installation media from their respective websites. Alternatively, you could use enterprise-centric distros like CentOS or Red Hat Enterprise Linux.
If you are not familiar with Linux or other UNIX-like operating systems, a good introductory tutorial can be found here.
Part II: Installing and Configuring Linux
Please note that the Installation of Linux that is described here will erase ALL the data that is currently on your server's hard drive. Therefore, if you have any valuable files on this drive, you should back them up before beginning the installation.
Once you have the installation media for your chosen Linux distro, you should follow the installation instructions provided to install the OS on your new system. When installing Linux, you will be presented with an opportunity to erase the data from your server's hard drive and partition it. use a custom partition scheme similar to the following (you should modify this scheme to fit your needs, or you can choose the default partitioning scheme provided by your Linux distro):
|/root||2 GB||Ext4 or XFS|
|/home||40 GB||Ext4 or XFS|
|/var||4-10 GB||Ext4 or XFS|
|/usr||20 GB||Ext4 or XFS|
|swap||8-10 GB (approx. twice the RAM in your system)||-|
|/||Remaining space on your HD||Ext4 or XFS|
Ext2 is a non-journaling file system that is fine for your boot partition. Other partitions on your HD should use a journaling file system such as ReiserFS (which used to be the standard on SuSE Linux) or Ext3 (the older journaling file system, which is simply Ext2 with journaling). Ext4 is a newer incarnation of Ext3 which the default file system for certain Linux distributions. XFS is a journaling file system developed by Silicon Graphics (SGI) and used to be the file system used by IRIX-based systems.
Furthermore, during the installation process, you will also be asked to choose a hostname for your system. In this article, I shall assume your hostname is 'homefileserver' (without the inverted commas). At this stage, it would be prudent to have your system issued with a static IP address by your router. You can assign a static IP address to your system in Ubuntu Linux by editing the '# The primary network interface' section of the /etc/network/interfaces file.
Once Linux is installed, boot into it and make sure you run the system updater that came with your OS to install any recent security patches, kernel updates, etc. that may have been released. All modern distros have automatic update notifiers that alert the user when updates are available. You should make sure your system is fully patched and updated before configuring remote access.
Part III; Setup and Configure Samba
After you have installed your Linux distro, you will need to install and configure Samba which provides file and printer sharing capabilities across multiple operating systems to your new Linux installation via the SMB/CIFS protocol.
To install Samba in a Debian-based Linux distro (such as Ubuntu), open a terminal and issue the following command;
sudo apt-get install samba
After samba is installed, you will need to configure it by editing the smb.conf file. However, before editing the smb.conf file, make a backup of it using the following command in the terminal:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
You can use any text editor you are comfortable with, however I tend to like Vi. To edit the smb. conf file in Vi, issue the following command in the terminal (If you do not know how to use Vi, a good tutorial can be found here):
sudo vi /etc/samba/smb.conf
You will need to edit the following sections of the smb.conf file:
workgroup = NAME_OF_YOUR_WORKGROUP
workgroup = MSHOME
Now add the following line beneath the workgroup line:
netbios name = YOUR_SERVER'S_NAME
netbios name = homefileserver
Finally, you will need to edit the [homes] section of the smb.conf file to match the following:
browsable = yes
writable = yes
You should save the changes to the smb.conf file and exit Vi (or the text editor you were using).
You will now create a user account and password to access your SMB share (your home directory). To create this account, issue the following command in the terminal:
sudo smbpasswd -a ENTER_YOUR_USERNAME
e.g. If your user name on your server is user1:
sudo smbpasswd -a user1
You will be asked to set your password and after doing so you should start the Samba service. If you use Ubuntu Linux, you may do so by issuing the following command:
sudo /etc/init.d/samba restart
You are now set. To access your new network directory from a Windows machine, you will need to map a network drive to the following location:
e.g. If your server's hostname is homefileserver and your user name associated with your SMB share is user1:
On a Macintosh running OS X, go to Go -> Connect to Server in the Finder and enter the following:
Once more, if your server's hostname is homefileserver and your user name associated with your SMB share is user1:
Part IV: Setup Remote SSH and SFTP access
Now that you have Samba setup on your server, you can install the SSH server so that you will be able to access your server remotely via the SSH protocol (over port 22). You can install open SSH on your server by issuing the following command (once again, this is for Debian-based Linux distros):
sudo apt-get install openssh
Congratulations! You home server is all set and, you can log into it remotely using the SSH protocol. You can even transfer files to any location in your server's file system using the SFTP protocol (since Samba limits your access via the SMB/CIFS protocol to your home directory).
A final concluding note: f you enable remote access and file sharing, you should also secure your network to prevent unauthorized access to your server and other networked devices. Here are my tips for securing your network .