Building your own Linux PC backup server

Professor Les Hatton of the UKC Computing Laboratory dirties his hands and builds a £250 PC and uses it as a network backup.

Just to show that even those in ivory towers have to mend the plumbing occasionally, in this article I will describe what it takes to build your own Linux PC from scratch and put it to good use as a backup machine. I'm old enough to remember the cost of proprietary mainframes and their national-debt sized maintenance contracts so it was a real revelation to realise how cheap and easy it is to build your own PC today and a nice change from studying software reliability which is my normal fate. The one I describe will very comfortably out-perform a Cray supercomputer I deployed fifteen years ago on behalf of a previous employer for approximately 0.001 % of the cost.

The first reaction of most people sufficiently consumed by curiosity to take the side off a PC, is to put it back on again quickly. However, in reality, there are very few pieces, they fit together in mostly logical ways and it is no more complicated than mending a push-bike and a lot cleaner. In the first half of this article, I will describe exactly what to do and what to watch out for those like myself who are dexterously challenged. Of course once you have built one, you also realise that they aren't that hard to fix either when they go wrong.

This article has two purposes however. When you have built your PC and got it up and running, I'd like to address the subject of backup, a vital subject for home and small business users. Although modern hard discs are exceptionally reliable, (about 10,000 times more reliable than 20 years ago), they still fail occasionally so you can't rely on one hard disc as the sole repository of your valuable data. One of the standard answers to this over the years since we outgrew floppies has been to use some kind of attached tape device, for example, DAT, Exabyte, Onstream or whatever. The idea is to keep multiple copies of your data on simple cartridges in these formats. Various schemes can be used. For a long time, I used 3 rolling backup copies and an archive copy kept at another site. The principle is simple: always have at least two recent copies of your data since the odds of losing them both is really very small. Keeping another copy offsite protects you against a disastrous fire for example. I have to say though that I have been very disappointed at the quality of the media. For example of 7 Onstream cartridges used in a backup cycle in the last year, 2 gave write errors after less than 10 uses and this at nearly £30 a cartridge. Exabyte cartridges have also given problems when read on drives other than the one on which they were written and of course most tape drives will set you back £500 upwards. In contrast, hard drives are stunningly reliable and generally of comparable cost to the cartridges let alone the tape drives which use them. They are also very much quicker than any tape drive. This therefore raises the possibility of backing up your data on spare hard drives in a purpose built PC.

Building the PC itself

So what do you need ? To actually build a PC, all I have used are a small cross-head screwdriver, preferably slightly magnetic to pick up rogue screws (but don't wave it around near floppy discs), a standard flat-head screwdriver with a fairly small head and some insulating tape to tidy up the wiring inside afterwards. In addition, you need a good light such as an angle-poise lamp and finally a magnifying glass is really useful when you are trying to read the hieroglyphics on the motherboard unless your eyes are much younger than mine.

Where do you buy the bits ? You can order parts for PCs by mail-order from a number of suppliers which you can find in any PC mag. They are generally rather cheaper to buy at a computer fair though and that's what I do. Be a little bit careful at computer fairs as some dealers are rather more opaque than others. What I usually do is wander round the fair checking prices first (they are usually pretty close though), and I only deal with suppliers who will give you a decent looking invoice. I would recommend going to a fair a couple of times before you buy anything expensive to get a feel for which suppliers are regulars and choose somebody who is geographically pretty close to you in case something doesn't work. Having said this, I have had no problems with the suppliers I now use and they all tend to sell the same stuff anyway and are generally very knowledgeable even about Linux compatibility these days. Go early to get the widest choice. So let's go shopping.

The bits

First of all you will need a case. These vary from around £20 to £200 or more for the person who is looking for something a little bit special such as custom cases packed with deep blue fluorescent lights to bathe their anorak in a sultry glow. Don't get the cheapest as the cases may flex a bit and this can lead to problems with PCI card seating whenever you pick it up. My last case was like this as I tried to shave a few pounds off my budget and I had to throw it away. For about £30 you can get a good case with a couple of fans already installed and most importantly a power supply. These are usually 300W or 350W which is more than adequate. Also, make sure you choose a case big enough for a standard ATX format motherboard. Avoid small cases like the plague unless your day job is a watch maker. You will thank me for this advice. If your case hasn't got any fans installed, you will have to buy one or two. They are only about £3 (don't forget to buy the fitting screws at the same time) and a cool computer is a happy computer. Note that the case should contain all the tiny fitting screws you will need, (except for the fans). Carry the case back to your car now or you won't be able to carry anything else making sure you get your hand stamped as you leave. If you look closely, it says nerd :-)

Figure Y1. The fan sitting on top of the heat-sink sitting on top of the processor.

Next, you will need an ATX format motherboard. There are many kinds of motherboard. For a mirror server such as we are building, you don't need anything fancy. I've used Gigabyte, ECS and Jetway motherboards satisfactorily. Note that some motherboards are designed for Intel chips and some for AMD. I much prefer AMD products as being cheaper and faster than their Intel equivalents but you may have a different view. For this project, I used an ECS K7S5A motherboard suitable for Socket A (Athlon and Duron) processors. This supports either SDRAM or DDR memory, (the latter is faster and a bit dearer but I'll come back to this) and has a AGP graphics card slot and 5 PCI slots. Look out for deals. Most suppliers will do you a deal consisting of a motherboard, processor of your choice and a processor fan for a few pounds off. (Note that the processor fan is an absolute MUST and is not to be confused with the case fan I discussed above). You can see it sitting on top of its heat-sink in Figure Y1, (the processor is hidden underneath).

I went a little over the top and got a K7S5A + Athlon XP1900+ + fan + 256Mb SDRAM for £150 but I notice that this price has already gone down more than £10 since, damn, damn, damn. An Athlon 1.2 Ghz. would shave quite a few additional pounds off to allow you to get DDR memory which is likely to have a much bigger effect on your system performance, (most modern machines are memory access time limited not processor limited). Now a word of advice. Fitting the processor fan is the single most nerve-wracking moment in building a PC. Most suppliers in computer fairs will fit both the processor and the fan if you ask. I built 4 machines before I dared to do it myself. Its your choice and you have been warned. If you decide to do it yourself, you will need a flathead screwdriver and nerves of steel. More later.

The rest is easy. Wander round and buy yourself the following; a hard disc (you can get IDE discs between 40 and 120 Gb. readily, you will have to decide how much storage you might need.) - I've used IBM and Seagate usually and a 7200 rpm 40Gb. disc is around £50; an AGP graphics card for £10-£20, (I usually use a Pine Nvidia TNT2 of various memory sizes for cheap machines); a 10/100 ethernet PCI card for around £6-8, (I used Realtek NC-100TX-R), a PS/2 keyboard and mouse as nearly all motherboards support them (£7 the pair); a floppy drive (about £7 new of usually unrecognisable origin) and of course last but not least, some kind of CD ROM drive. I usually use Liteon DVD players (£30). As a small note, although we are only building a server, it only costs a few more pounds to add a reasonable graphics card, the DVD drive and a reasonable sound card (I used the Xwave-7000 which is Linux and SoundBlaster compatible) to make the PC far more general purpose. Its your choice. If you are just using it as a server, you can do it for a good £40 cheaper than I paid. Note that the motherboard will include the cables you need to connect the IDE devices (hard disc and DVD or CD) and the IDC floppy but in my experience the supplied IDE cable may not be very generous so buy yourself a separate IDE cable of around 75cm. as you can always tie it up at the end if its a bit long. It will cost about £4. That's it, shopping done, now to the business of assembling it. I spent £267.

The assembly

Find yourself a flat workspace with a really good overhead lamp. Remove the screws on the back of the case which hold the side on, (usually 2 or 3 down the right hand edge as you look at the back). Remove the side, (usually by sliding it about 2 cm. towards the back of the case). Lay the case down flat, removed side upwards and unravel the cables from the power supply (top left as you look in the box) and the front panel cables which come from the right. Hang them over the side of the box out of the way. Plug the supplied power lead in the back of the computer and plug it in a wall socket but not switched on. This earths the case. Touch the case before you handle each component to discharge any stray static. This can damage electronic components, (I never have but this is probably because I am a dull computer scientist. If I was a TV quiz show presenter I could probably blow a memory module just by thinking about it.). Take the motherboard carefully out of its sleeve, lay it flat on its insulating mat on the desk with the ports, (serial, PS/2, USB and so on) on the left. Inspect the ports and then look at the back of the case. You will find matching templates there. Push the appropriate ones out by pushing them gently with a screwdriver and then waggling them until they come off. You should also choose now which PCI slots you are going to use (see Figure Y3) and remove the blanking plates on the back of the case the same way.

Motherboard first

I am assuming that your motherboard has the processor and processor fan already mounted. If they aren't, you will have to fit them. First make sure the motherboard is well supported underneath. To fit the processor, lift the ZIF (Zero Insertion Force) lever on the side of the processor socket, touch the case then rotate the processor until it matches the holes on the socket, drop it in gently and lower the lever. The motherboard manual will show you how to do this. Do NOT force it. After fitting the processor, fit the processor fan, a big chunky thing. You have to line up the metal tags on the side of the fan with the plastic tabs on the side of the socket holding your processor. Place on top of the processor, fit one side and then use a screwdriver to fit the other side. At this point you will be wishing you had asked the supplier to do it. If you manage to do this without plunging the screwdriver through the motherboard, then read on. At this moment, take the opportunity to attach the small power lead from the processor fan onto its socket on the motherboard (nearby and called something like CPU FAN - you can see it just to the right of the processor in Figure Y1). From now on, its plain sailing.

Looking into the case, you will see numerous holes in the bottom as you view it. If you now look at the motherboard you will see 6 mounting holes in the motherboard. In the packet which came with the case, you will find lots of little odd-looking screws and 'stand-offs'. You will have to use your imagination to choose the right ones. If you can't figure out which to use, take all the parts back now and ask for asylum. Put the stand-offs in the case to line up with the motherboard to suspend it a couple of mm. above the case bottom. Use all 6 to keep the motherboard stable when you have to push the cards in later. Now carefully pick up the motherboard and rest it on top of these and screw it to the 6 stand-offs. Don't fit the memory yet. Lastly, fit the funny shaped plug on the power supply into the motherboard, (you can see this on the left of the processor on Figure Y1).

CD-ROM, discs and so on.

Fitting these is usually easy. The only complex bit is making sure they are jumpered correctly. If you look on the back of the CD-ROM and hard disc, you will find a series of little connections with a jumper fitted over one. You can see the hard disc jumper in Figure Y5 near the centre next to the power lead.

Figure Y5: A close up of the hard disc and its jumper and cabling

They will be probably be configured correctly but the CD-ROM should be a slave device and the hard disc should be a master device. It will tell you on the back of the device in almost invisible writing. Reach for the magnifying glass at this point. Next push out the plastic cover on the front of the case from the inside where you want to fit the CD-ROM. Sometimes there is a metal blanking plate in the way which you should waggle loose and remove. Then slide the CD-ROM from the front into the case and secure it with two attaching screws from the stash that came with the case. Most cases have guiding rails so this should be easy. Next slide the floppy drive into its cage further down this time from the inside making sure it is pushed in as far as it will go or you will not be able to eject the floppies. Attach the floppy drive with its attachment screws. Now slide the hard-disc in above it also from the inside and secure. At this point you will see why it is a good idea to fit the memory last. Note that the CD-ROM will have a sound cable included with it which usually fits on the motherboard immediately underneath the AGP slot so fit the CD-ROM sound cable at the motherboard end now and hang the other end over the side of the case.

The graphics board, PCI boards and memory

Fit the graphics board first. This goes into the AGP slot on the motherboard above the white PCI slots as shown in Figure Y3. Fitting boards into slots on the motherboard is always a bit unnerving. You have to push surprisingly hard but make very sure the board is lined up properly in the slot first. You will hear them click home. You should also know that incorrectly fitting boards is the primary suspect if your creation won't boot properly later. When you have fitted the graphics card, screw it to the back of the case with a single screw on top, (although this depends on the case).

Figure Y3: This shows the graphics card seated in its AGP slot and 5 PCI slots the second of which is occupied by the 10/100 network card and the fifth by a sound card.

Fitting the PCI boards is done in exactly the same way. Push them in carefully but firmly into the slots you chose at the beginning and fix them with the fixing screw to the back of the case. Finally insert the memory in the appropriate socket on the right hand side of the board. SDRAM or DDR are fitted the same way and you can't fit them into the wrong slots or the wrong way round any more. Again push in firmly and then attach the catches at each end to engage with the slots in the ends of the memory module.

Cabling up

We're now ready to cable it. First fit the IDC cable (one of the two ribbon cables that came with the motherboard) to the floppy. This is about the only thing you can fit the wrong way round, (and only at the floppy end). As you look at the back of the floppy the cross-over bit in the cable should be on the left. Then fit the IDE cable into the socket marked IDE1 on the motherboard and then fit the other two plugs to the CD-ROM and the hard disc. This is where your longer IDE cable can help. Either order of plugs is OK as the jumpers on the devices tell the motherboard which is the master and which the slave. You can tweak a bit of extra performance by using a second IDE cable in socket IDE2 and using IDE1 for the hard disc and IDE2 for the CD-ROM but I have no idea how much extra performance this buys you. Figure Y4 shows the IDE and IDC cabling.

Figure Y4: The IDE and IDC cabling.

I'm assuming that you can also fit the CD-ROM sound cable (it comes with the CD-ROM) now or you have already fitted it as noted earlier. A finally fiddly bit is fitting the wires which come from the front panel onto the motherboard. These are labelled things like HDD LED (disc light), POWER LED (power light), RESET SW (software reset) and so on. Fit them into sockets on the motherboard usually down the bottom according to the manual which accompanies the motherboard. THIS is where you need a magnifying glass and preferably a tame leprechaun. The three I've mentioned above are always present. Some of the others may not have anywhere obvious on the board to plug them. Just tie them up in this case. Nearly there now. The last thing is to attach the power leads from the power supply to the various devices. These will only go in one way round and there are more than you need so just plug away. Make sure you power the hard disc, the CD-ROM and the floppy. The floppy is a bit fiddly. If you have two case fans, one can be powered off the motherboard (look for the SYS FAN connector) and the other directly from the power supply. This is a good time to tidy everything up with insulating tape.

The end product should look something like Figure Y2.


Now for the moment of truth. You are going to boot it. You might as well be optimistic and have the boot floppy and CD of your favourite distro handy. Most times, the machine will boot straight away, (although I leave the side off to start with just in case but DON'T go groping around inside with the power switched on). You will normally need to press the F1 key or somesuch on bootup to get into the BIOS to set things like system time. On a few occasions I have had to tell the BIOS to detect the IDE devices because it didn't find them automatically but I have never had to do anything else. If you get this far, consult other issues of this estimable magazine to see how to install your distro. I am currently using SuSE 7.3 and 8.0. Installing SuSE 8.0 is a complete no-brainer - wonderful. The Linux community has made huge strides in recent distro installation. In comparison, I recently had to install Windows '98 3 times reformatting each time before I got it to take. I've no idea why, I did the same things each time. With SuSE 8.0 you'll be up and flying in 30 minutes. I'm assuming you're capable of setting up the network configuration so that it can talk to the other machine(s) on your network.

Figure Y2: The finished article, rotated through 90 degrees to fit.

However, it might not boot :-( In every case in my experience, this has been due to the graphics card not being seated properly. The symptom is that the machine flashes its lights and beeps as it starts but nothing appears on the screen. Most home constructors will tell you that ill-fitting AGP or PCI boards cause most boot failures. Just switch it off and reseat them carefully. So far this has never failed me. If it fails you I can't help, so you might try books like "How to build your own PC" by R.A. Penfold, ISBN 0-85934-479-7 for more detail than I can cover in this article.

Setting it up as a network backup

At this point, you should now be basking in the satisfaction of having built your very own computer. So let's set it up to do something really useful like backing up selected directories on your network. Figure Y6 is a paired down listing of a bash script which achieves this goal. The script runs on each machine which needs to be backed up although of course the directories to be backed up will differ in general.

The strategy is explained in the script comment header. Its very simple. The key is the power of the find command in section a) of the script which checks for changes against the last time the directories dir1 and dir2 were backed up. It then zips them up, (the -@ option tells zip to use the standard input), ships them over to our new creation and then unzips them there mirroring the original file structure. Finally, it touches the file last_update_xxxx where xxxx is the name of our new backup machine to update the 'time of last update'. I have left out error recovery as an exercise to the reader. As it uses the secure shell copy scp to move files between machines, you will either have to enter the password to allow this (twice), or set up the machines as trusted. You can also add other frills like starting the backup script automatically at regular periods using a cron entry.

The process is extraordinarily fast. I back up a 2Gb. archive several times a day across several machines in less than five minutes. I still have a 10baseT network so it would be much faster if I had a 10/100 as the zip / unzip time is relatively short. What a wonderful program zip is !

For security, I have 3 backup machines. Two are onsite and the third is a laptop which is kept offsite.

Figure Y6: The backup script

#       Back up any changes in selected sub-directories of the /home directory
#       to our new back up machine.
#       This is accomplished as follows
#               a)      Find everything which is newer than the touch file.
#               b)      Create a zip file of these files.
#               c)      Copy the zip file to the machine to be updated.
#               d)      Unzip the zip file on the machine to be updated.
#               e)      Update the local log and touch files.
#       Revision:       $Revision: 1.6 $
#       Date:           $Date: 2002/12/28 18:42:49 $
if test $# -ne 1
        echo "Usage: update_home [machine_name]"; exit
#       Set up various values and temporary files

rm -f $upd $zipa
#       If this is the first time, create the last update file in pre-history
#       so that everything gets copied.
if test ! -f $touch_file
        touch -t 197001310000 $touch_file
#       Define the directories to back up from this machine.
#       We exclude the home directory because the environment stuff
#       may be different on the backup and we don't want to overwrite that.
dirs=" \
        dir1 \
#       Section a) The all important find command.
for dir in $dirs
#       Find files which have changed since the last time the touch_file
#       was updated.
        echo " .. $dir"
        find $bdir/$dir -newer $touch_file -type f -print       >> $upd

echo ""
echo    "++++++++++++++++++++++++++++++++++++++++++++++"        >> $log
echo    "Update of $bdir on machine $1 at `date`"               >> $log

chmod +x $upd
#       Section b) Building the zip archive.
zip $zipa       -@ < $upd

#       Section c) Transfer the zip archive to the backup machine
scp     $zipa $1:/home/lesh     
#       Section d) Unzip with the silent options.
ssh     $1 "cd /; unzip -o ~/$zipa"

echo "+++++++++++++++++++++++++++++++++++++++++"
echo "$bdir updated on machine $1"
echo "+++++++++++++++++++++++++++++++++++++++++"
#       Section e) Update the touch file and clean up.
touch $touch_file
rm -f $upd $zipa

Supposing I have two machines, one called original and the one we have just built called eureka. Simply install this script on original in a file called update_home say and use it by typing:

% update_home eureka

One final wrinkle - the above script will fail if the initial zip file size exceeds some OS dependent value like 4Gb. In this case just copy the entire directory system first using scp -r (recursive copy). Thereafter the above script will be fine so long as incremental changes do not exceed this which should satisfy most users. That's all. Hope you have fun building your machine.

© Copyright, Les Hatton, UKC, 2002-, version $Date: 2002/12/28 18:42:49 $ Page ..