Simple Home File Server (Based On Ubuntu)

Posted on January 23, 2012. Filed under: Uncategorized |

This tutorial explains how to turn an old PC with additional hard disks into a simple home file server. The file server is intended for home use. The home file server is accessible by Windows and Linux computers in the home network.
The existing tutorials do not describe how to add additional disks or have a complex authorization or access procedure. Freenas (www.freenas.org) does have too many features for home users and more important it does not support the NTFS format. 
This Home File Server can work with hard disks formatted in NTFS. So when you need or want to move the hard disk into a new computer, they are accessible by Windows and most Linux operating systems.
The server is built with Ubuntu Server 7.10 & Samba. Do not use Ubuntu Server 5.04 LTS because this version does not support the latest SATA Controllers (in an Pentium II or III you likely want to use a PCI SATA RAID controller to attach SATA hard disks).
I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

1 Requirements

To install such a system you will need the following:

The hard disks for data storage in the file server must be formatted in the NTFS format. You can use the Gparted live CD to do this job, download the iso from:http://sourceforge.net/project/showfiles.php?group_id=115843&package_id=173828
I assume that you already know how to install a hard drive. I also assume that you knew how to make it a master or slave, you’ve checked to make sure that it shows up in bios, and that it was intalled properly. 

2 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100 and the gateway 192.168.0.1. These settings might differ for you, so you have to replace them where appropriate.

3 The Base System

Insert your Ubuntu install CD into your system and boot from it. Select Install to the hard disk:
The installation starts, and first you have to choose your language:
2.png
Then select your location:
4.png
Choose a keyboard layout (you will be asked to press a few keys, and the installer will try to detect your keyboard layout based on the keys you pressed):
The installer checks the installation CD, your hardware, and configures the network with DHCP if there is a DHCP server in the network:
Enter the hostname. In this example, my system is called server1.example.com, so I enter server1:
Now you have to partition your hard disk. For simplicity’s sake I will create one big partition (with the mount point /) and a little swap partition so I selectGuided – use entire disk (of course, the partitioning is totally up to you – if you like, you can create more than just one big partition, and you can also use LVM):
Select the disk that you want to partition. Please do not use the NTFS hard disk intended for data storage:
Afterwards, your new partitions are being created and formatted:
Configure your system’s clock. Normally UTC is a good choice:
Create a user, for example the user Administrator with the user name administrator (don’t use the user name admin as it is a reserved name on Gutsy Gibbon):
Now the base system is being installed:
We need a Samba File server, but nevertheless I don’t select any of them now because I like to have full control over what gets installed on my system. We will install the needed packages manually later on. The only item I select here is OpenSSH server so that I can immediately connect to the system with an SSH client such as PuTTY after the installation has finished:
The installation continues:
The base system installation is now finished. Remove the installation CD from the CD drive and hit Continue to reboot the system:
From now on you can use an SSH client such as PuTTY and connect from your workstation to your Ubuntu Gutsy Gibbon server and follow the remaining steps from this tutorial.

4 Enable The root Account

 
After the reboot you can login with your previously created username (e.g. administrator). Because we must run all the steps from this tutorial as root user, we must enable the root account now.
Run
sudo passwd root
and give root a password. Afterwards we become root by running
su

5 Configure The Network

Because the Ubuntu installer has configured our system to get its network settings via DHCP, we have to change that now because a server should have a static IP address. Edit /etc/network/interfaces and adjust it to your needs (in this example setup I will use the IP address 192.168.0.100): 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
Then restart your network:
/etc/init.d/networking restart
Then edit /etc/hosts. Make it look like this:
vi /etc/hosts
127.0.0.1       localhost.localdomain   localhost
192.168.0.100 server1.example.com server1

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts#
Now run
echo server1.example.com > /etc/hostname
/etc/init.d/hostname.sh start
Afterwards, run
hostname
hostname -f
Both should show server1.example.com now.

6 Edit /etc/apt/sources.list And Update Your Linux Installation

Edit /etc/apt/sources.list. Comment out or remove the installation CD from the file and make sure that the universe and multiverse repositories are enabled. It should look like this:
vi /etc/apt/sources.list
#
# deb cdrom:[Ubuntu-Server 7.10 _Gutsy Gibbon_ - Release i386 (20071016)]/ gutsy main restricted

#deb cdrom:[Ubuntu-Server 7.10 _Gutsy Gibbon_ - Release i386 (20071016)]/ gutsy main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://de.archive.ubuntu.com/ubuntu/ gutsy main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ gutsy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://de.archive.ubuntu.com/ubuntu/ gutsy universe
deb-src http://de.archive.ubuntu.com/ubuntu/ gutsy universe
deb http://de.archive.ubuntu.com/ubuntu/ gutsy-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ gutsy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://de.archive.ubuntu.com/ubuntu/ gutsy multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ gutsy multiverse
deb http://de.archive.ubuntu.com/ubuntu/ gutsy-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ gutsy-updates multiverse

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://de.archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository. This software is not part of Ubuntu, but is
## offered by Canonical and the respective vendors as a service to Ubuntu
## users.
# deb http://archive.canonical.com/ubuntu gutsy partner
# deb-src http://archive.canonical.com/ubuntu gutsy partner

deb http://security.ubuntu.com/ubuntu gutsy-security main restricted
deb-src http://security.ubuntu.com/ubuntu gutsy-security main restricted
deb http://security.ubuntu.com/ubuntu gutsy-security universe
deb-src http://security.ubuntu.com/ubuntu gutsy-security universe
deb http://security.ubuntu.com/ubuntu gutsy-security multiverse
deb-src http://security.ubuntu.com/ubuntu gutsy-security multiverse
Then run
apt-get update
to update the apt package database and
apt-get upgrade
to install the latest updates (if there are any).

7 Install Some Software

apt-get install samba smbclient smbfs beep ntp ntpdate
Samba, SMBlient and SMBFS form the base of the home file server. NTP and NTPdate will keep the time synchronized. Beep is needed to let the PC-speaker beep when the file server is up and running.

8 Install The Second Hard Disk

First we need to find out what name Ubuntu has given to the second hard disk:
fdisk -l
You should get a listing of the hard drives installed on your PC. There will be a little paragraph for each one that will look like this:
Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hda1 * 1 4678 37576003+ 83 NTFS
In Windows disk drives are assigned an alphabet letter.The main hard drive was c:/. In Linux it’s kind of the same, but in a different format. All hard drives installed are listed in the ‘device’ or /dev directory. All drives start with theprefix “hd” ( ‘hard drive’). I will now show the steps to add hda1.
Now we create a mount point:
mkdir /media/store
This mount point will get writable permissions for all users:
chmod 777 /media/store
The hard disk hda needs to be mounted:
mount /dev/hda /media/store
This is a temporary mount. In order to do his automatically at every boot, we need to:
vi /etc/fstab
The text editor window will appear with the fstab file loaded up. You will see something that looks kind of like this:
# /etc/fstab: static file system information.
#
#

proc /proc proc defaults 0 0
/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hda5 none swap sw 0 0
/dev/hdb1 /media/hdb1 ext3 defaults 0 0
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
All you have to do is add a new line for the new drive… I will add the following line to my fstab for my new drive:
/dev/hda1 /media/store ntfs defaults 0 0
To make the hard drive show up right now, without rebooting – just reload your fstab file with the following command:
mount -a

9 Configure Samba

The Home File server must be visible in the home network. The default value is MSHOME. If your workgroup has a different name edit:
vi /etc/samba/smb.conf
and change the line:
workgroup = MSHOME
Make the hard disk hda visible and writeable for all users, add the following lines to the bottom of smb.conf:
[hda public hard disk]
comment = Public Folder
path = media/store
public = yes
writable = yes
create mask = 0777
directory mask = 0777
force user = nobody
force group = no group
Now Linux users can log in to the Home File server.
Save and exit the vi editor and restart Samba:
/etc/init.d/samba force-reload
For home use one user name is sufficient. In this example I will add the user family:
smbpasswd -a family
Fill in a password at the next prompt. Now you are able to use family as user if you access your home file server from Internet Explorer.

10 Beep

Your home file server will probably not have a turned on or attached monitor. So when you start up your home file server you do not excatly know when Ubuntu and Samba are loaded and can be used in the home network.
By making the PC-speaker beep 3 times, you will know that the system is ready:
vi /et/rc.load
Simply add this line:
beep -l 900 -r 3 -f 500
Now  reboot and enjoy your own Home File Server:
shutdown -r now

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: