loading

Turning an old PC into a file server, the Gentoo way

Picture of Turning an old PC into a file server, the Gentoo way
C:\Documents and Settings\Michael\Desktop\dscf0034.jpg
I daresay there's many of us that have an old PC or two lurking around in the depths of cupboards, or just sitting unused under desks. Articles on what to do with old PCs crop up time and time again, but in this day and age PC's from a few years back with ample hard drive space and specifications in the region of 1Ghz and above seem to be classed as old - I'm not really talking about those. Personally, I think such a machine is still completely usable as a desktop system - I own a couple, and while not being able to run any graphically intensive game at a playable rate, they're more than capable of playing older games, and again more than suitable for day to day office work.

The machine in question for this instructable (my first, so please don't go too harshly!) is around 12-13 years old, and when new ran the latest graphically intensive Windows 95 games at a mind boggling resolution of 800x600. It remained the faithful family computer for quite some time, but it's been sitting doing nothing in my room for a few years now, and I decided it was time to see if it could be put back into action.

I thought of several possibilities other than a file server, and all could be equally valid - a static content web server, a machine for experimenting on, a router, a firewall - all were possibilities. I even thought about using it as a computerized method of controlling my ever expanding train set. However, personally a file server met my needs best - I have no need for a web server, I have a router and firewall, and the train control idea can wait until I've done a bit more research on the subject.

Next, why Gentoo? Yes there's ways to do this using windows, and an article popped up on digg a while back about it if I remember correctly. However, you're looking at reduced performance, security, and increased bloat when going down the windows route - especially for an old machine such as this where an outdated version of windows would have to be used to gain any level of respectable performance. I've gone for Gentoo because it's a distribution designed to be tinkered with, and that's what we'll be doing later. If I was feeling really brave (or indeed you are) you could give LFS a try, but getting that up and running would probably be a series of instructables in itself. Gentoo's not the easiest system to get running, but it's still entirely feasible and there's a huge user base on forums if you get stuck.

So on with the materials list, you will need the following:

An old computer, to use Gentoo this will need to be at least a 486 (My choice is an aging Pentium 90Mhz, S3 Virge graphics card, with 80MB RAM upgraded from an original 16MB.) This should work on anything 486 and above, you could use a 386 (I think) with FreeBSD, but Gentoo should be much flexible and faster as well. Your limit is that defined by the Gentoo minimal install CD, that being 64MB of RAM and at least a 486. The biggest issue here is probably going to be RAM, but you can probably pick up some cheap old sticks on ebay for not a lot.

A network card - my PC didn't have one originally installed, so I've gone with a basic 10/100 Belkin card. Gigabit is overkill here, you're not going to be looking at anywhere near those speeds with a low end computer like this.

A new hard disk - being an old PC, this will almost definitely not have the space required that we need for a file server. It doesn't need to be huge by today's standards though, in fact it can be tiny - I've opted for a spare 40GB model I've got lying around. A word of warning however for those that aren't aware - the older the PC, the smaller the chances of the BIOS recognizing the drive - mine didn't. Gentoo should still recognize the drive anyway (though I can't guarantee this, it worked for me) but this makes booting into your system a right pig. We'll try to address this issue later.

A CD-ROM drive - if your computer hasn't got one, you should be able to borrow one off another computer temporarily.

The ability to leave your computer on for quite a while - Gentoo compiles everything from source, which is fantastic for speed optimizations once it's all done, but it means it takes a while in doing it. Technically speaking you don't HAVE to leave it on, but it makes it a heck of a lot easier if you do.
 
Remove these adsRemove these ads by Signing Up

Step 1: Cleaning and Stressing

If you're going to be relying on your server to any extent, you'll want to make sure it doesn't collapse out or give up suddenly, and this is where this step comes in. Some may be tempted to skip it, and to be honest if you know your system is completely fine then you're probably OK skipping this step. However, I'd personally still recommend it.

Though please bear in mind, whatever testing you're using, this is an OLD system, please make sure your data is backed up elsewhere - just in case!

First of all, have a mini vacuum cleaner and a can of compressed air handy. Then open the case and (gently) get rid of as much dust and gunk as possible. When you've done this, unplug the various cables, blow the dust away from there and then reseat them (in their original positions!) It's good practice to clean any PC like this regularly, and with something that hasn't been used in a while it's good to give it a fresh start!

Right, next on to testing the system.

I'd recommend StressLinux for this, it's a livecd distribution that's designed to run a series of tests on hardware, and includes memtest. Now if you're in the same situation as me you'd now be thinking something like "I'm stuck with a computer that's completely incapable of booting from CD!" However, all is not lost, we simply need a bit of extra help, and this is where Smart Boot Manager comes in. It's a neat little utility that boots from a floppy, then gives you options to boot from everywhere on your system it can.

Follow the link above to download stresslinux, then burn the ISO image to a CD, being careful to create a disk from the ISO image and not simply copy the ISO file onto a CD - that won't do anything useful. If you need it, download and install smart boot manager to a floppy. Set your BIOS to boot from the relevant medium, and stresslinux should fire up.

To start with, I'd test the memory. Type in "memtest" (no quotes) into the boot: prompt and press enter. Leave it to it's own devices for a good few hours - the longer the better. You should have no more than a couple of errors at most, preferably 0, after this time. If the number of errors is high or rising significantly, you most likely have a problem that will prevent you using anything with more than a minimal degree of reliability, if at all. Look into this before you progress further.

After memtest has run for a few hours and assuming there are few or no errors, reboot your system and boot back into stresslinux, this time just hit enter when greeted with boot:, and follow it's steps through to set it up. When it's running, run badblocks on your hard drive and CD-ROM drive, you should have, again, no more than a couple of bad blocks on each, if that.

To run badblocks, simply type badblocks followed by the drive, which will probably be:

/dev/hda for the primary master
/dev/hdb for the primary slave
/dev/hdc for the secondary master
/dev/hdd for the secondary slave.

The most likely configuration is that the hard drive is on /dev/hda and the CD-ROM is /dev/hdc. So to run badblocks for the hard drive:

badblocks /dev/hda

and for the CD-ROM:

badblocks /dev/hdc

Be patient and wait for it to complete. Assuming no problems, you're now ready to start the Gentoo installation procedure.

Step 2: Preparing the System

Picture of Preparing the System
Now that you've tested the system and cleaned it all up, think practically. The installation is likely to take a while, so install any hardware you need (if you need to put a network card in, for example, or swap any bad components) and put the cover back on. Make sure things are secure inside the case, and find a well ventilated spot where the machine won't get kicked, knocked, pushed over etc. If you had to swap a bad component, make sure you follow the testing steps again to make sure all is well. It takes time, but it's better to be safe.

Download the Gentoo minimal install CD (not the live one, your system probably won't have anywhere near the resources to run it) and boot the CD. If you're whining about not being able to boot CD's then skip back to step one. Told you not to skip over it did I not? ;)

For most users, simply hitting enter should get you into a working shell inside your livecd. If it crashes out, try the kernel cheat options - i had to use "gentoo acpi=off" before mine worked. Bear in mind you might be looking at upwards of half an hour just to wait for the thing to boot - don't worry, it'll be quicker than this in the final system, but I did say that things would initially take a while.

Type in ifconfig into the shell and press enter, chances are your network is set up (mine was.) If so, you'll see eth0 listed, and typing something like ping -c 3 google.com should be successful. If this is the case, take a note of the IP address assigned to eth0 and then you're ready to go. If not, try net-setup eth0. Internet is not optional, you HAVE to get it working to install Gentoo, so this isn't something you can leave until after the installation.

Next, although this is optional, I type:
/etc/init.d/sshd start
passwd

This changes the auto scrambled password to something memorable, and starts the ssh demon This will enable you to do the entire installation remotely from another computer, which means much less darting back and forth. When the ssh demon has started and you've changed the password, download an ssh client such as Putty, enter the IP given by ifconfig into it and connect. You should then be able to log in with the username "root" and the password you selected. On with the installation!

Step 3: Setting up the Disk

(Note: From this point onwards, much of what I say is duplicated in the official Gentoo Handbook, starting from here. However, I'll probably make recommendations or deviate slightly from what's being said there, so I'm still going to go step by step through the install.)

Next, you need to create a partition table for your hard drive, which is done by the wonderful infamous utility named fdisk. This is the *nix fdisk, not the windows one. This one is actually decent. To start with, fire it up by typing "fdisk /dev/hda" (from this point on I'm assuming you're sensible enough to replace /dev/hda with your hard drive address and not type the quotes in.)

To start with, we need to delete all the existing partitions on the disk so we can start from scratch. Type "p" then hit enter to see the current partition layout - all these need to go (if there are any.) Hit "d", then "1" when prompted as to the partition that is to be deleted - this will delete partition 1. Repeat until "p" gives a blank partition table.

Next you need to make new partitions - you could just leave the whole disk as a partition, but I wouldn't recommend it - what I've done is to create seperate partitions for boot, the swap file and user data, and I suggest you do the same.

First, the boot partition:

"n" for new partition
"p" for primary partition
"1" for the first partition
Hit enter for the default first cylinder value
"+32M" to create a partition 32MB in size

Next, the swap partition:

"n" for new partition
"p" for primary partition
"2" for the second partition
Hit enter for the default first cylinder value
"+512M" to create a partition 512MB in size (this may be overkill for an old system, but better to be sure)

Finally, the data partition for the rest of the disk:

First, the boot partition:

"n" for new partition
"p" for primary partition
"2" for the third partition
Hit enter for the default first cylinder value
Hit enter to fill the rest of the disk

Now we need to set the swap partition as the right type, and the boot partition as bootable:

"a" to toggle boot flag
"1" to put it on the first partition
"t" to select partition type
"2 to select swap partition
"82" to select Linux Swap

Next, hit "p" again, and 3 partitions should be there of the sizes specified earlier, and there should be an asterisk by the first partition (this indicates it's bootable.) If everything is OK, hit "w" to write the partition table to the disk then exit.

When everything has written, we need to decide on our filesystems. For booting, ext2 is really the best choice, and for swap you have to use - swap. So lets get those out the way, and activate the swap:

mke2fs /dev/hda1
mkswap /dev/hda2
swapon /dev/hda2

Now you need to decide on the filesystem that you'll use for your main partition. You have the choice between ext2, ext3, jfs, reiserfs and xfs. Realistically, no-one really uses ext2 for the home partition, which leaves you with the latter 4 options. If you're like me and power outage isn't a problem, I'd go with XFS. Realistically it's the fastest out of the 4, unless you're dealing with lots of tiny files in which case reiserfs would probably take the lead. If you don't want your CPU constantly throttling however (which it may well do, and which shouldn't be a problem if you're just using the box as a file server) then it might be better to give JFS a try, it's slightly slower but a bit kinder on CPU usage. To make my XFS partition then:

mkfs.xfs /dev/hda3

To use another filesystem, use mkfs.jfs for JFS, mke2fs -j for ext3, mke2fs for ext2, and mkreiserfs for reiserfs.

When your filesystems are created, mount them and change to your home filesystem directory :

mount /dev/hda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/hda1 /mnt/gentoo/boot
cd /mnt/gentoo

When the above is done, we'll get on with the actual installation.

Step 4: Beginning the Installation

To start with, we need to grab a stage3 tarball and a portage snapshot. We'll start with the former, type in the following:

links http://www.gentoo.org/main/en/mirrors.xml

Navigate through the mirror of your choice to releases/x86/yourversion/stages/, and then pick the tarball that matches your architecture and version. If you're not sure, then type "arch" into the shell, this will tell you whether you're 486, 586 or 686. When you've found the right tarball, download it using links (it could take a while) and then exit links, make sure you're still in /mnt/gentoo and type:

tar xvjpf yourtarballname.tar.bz2.

Copied from the handbook in case you're wondering:

"The x stands for Extract, the v for Verbose to see what happens during the extraction process (optional), the j for Decompress with bzip2, the p for Preserve permissions and the f to denote that we want to extract a file, not standard input."

Next, we'll grab a portage snapshot. Open up your mirror list again:

links http://www.gentoo.org/main/en/mirrors.xml

Then choose a mirror, and navigate to the snapshots directory and download "portage-latest.tar.bz2". When downloaded, exit links and type:

tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

This will install the portage snapshot.

We're almost at the stage where we'll enter our new environment, but before we do:

cp -L /etc/resolv.conf /mnt/gentoo/etc/

That will copy over the networking information to make sure it still works. We also need to mount the /proc and /dev filesystems:

mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev

And we're ready to go in! Simply type the following commands in order:

chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile
export PS1="(chroot) $PS1"

Next comes the beginning of the strip down process. Open your make.conf with nano:

nano -w /etc/make.conf

We now need to edit the USE flags. We're not installing X, KDE, Gnome or using any sound facilities, so we can turn all these off:

USE="-gtk -gnome -kde -dvd -alsa -oss"

This will stop applications being compiled with the above support, resulting in unnecessary bloat being removed. This is where Gentoo comes in handy, with other distributions all the use flags would simply be enabled by default.

Next, it's good practice to set the timezone before we go any further:

ls /usr/share/zoneinfo

The above will list the available timezones, you simply need to copy the one you need as /etc/localtime. So say you wanted GMT, as I did:

cp /usr/share/zoneinfo/GMT /etc/localtime

Next, it's compiling the kernel time :)

Step 5: The Kernel

The kernel is the heart of linux, and with most distributions you're given a preset kernel containing all the features you're realistically going to use. You can do the same thing in Gentoo, it's called genkernel and it's what the livecd used to boot. Great as this is for detecting hardware, it's just bloated and unnecessary - so now we're going to download the sources, go through the kernel and get rid of everything we don't need (as well as selecting some bits we do), then compile it. It's a good idea to update your portage tree before grabbing the sources, so we run the following command to do both:

emerge --sync && emerge gentoo-sources

When the above has finished:

cd /usr/src/linux && make menuconfig

The above will drop you into your kernel configuration. I can't tell you what options you will and won't need for definite, the best thing to do is to do some research as to what drivers you require for your hardware. If you're not sure what something does, then you're probably fine leaving it enabled, but this will result in a larger kernel, perhaps unnecessarily. Rather than try to explain everything and reinvent the wheel, I'll point you to here. That gvies you a good idea of what to do, what you need and what you don't. However, in addition you will NOT need the following:

Any multimedia support (ALSA, OSS, V4l can all go)
Any filesystems you're not using (in my case JFS, EXT3, Reiser can all go)
USB and Firewire support (extremely unlikely you're using it)
ACPI support
Any drivers you won't need (gigabit networking can all go for example unless you've specifically got a gigabit card, sound card drivers can all go, so can graphics and framebuffer support)

However, you will definitely need the following:

Support for all the filesystems you're using (ext2 and XFS here)
Support for NFS filesystems, SMB and CIFS support (all in network filesystems)
Support for the network card and any other devices you're using.

I'd compile everything into the kernel, not as modules - makes things easier. Then hit escape to quit, making sure you save your changes. Next, you can compile the kernel:

make && make modules_install

I ran the last command even though I shouldn't have needed to, since I don't think I had any modules. Regardless, better to be safe as I've always done it that way in the past. This will probably take a while. Go order a pizza or take the dog for a walk. Seriously, this could take all day! Be patient, and when it's finished proceed to installing the extra packages you need.

Step 6: Finishing off the installation

Next, follow this link, and follow the instructions up until you've finished configuring the bootloader. There's no difference, the only thing you need to bear in mind is that you don't need framebuffer support, it's a waste of time in this case.

When you're done, you should be able to reboot into your new Gentoo installation. Remove the disks from their drivers, and type in "reboot". You should now have installed Gentoo and be inside!

However, we've now got to install all the extra packages that will turn the box into a file server. This will probably take a heck of a long time, perhaps days on end, and for this reason I suggest you type the commands in together so they execute one after the other. First, we want SMART. At least I did, and it's a good idea, since it can warn you if your disks are about to die! You'll probably also want NFS and SAMBA installed (samba lets you interact with windows machines on the network natively. Look through here and make sure you set the use flags you want in /etc/make.conf (nano /etc/make.conf) before you emerge. For example, you probably want to add the swat and samba use flags at a minimum. Then you can emerge all the applications at once:

emerge smartmontools && emerge nfs-utils && emerge samba && emerge ntp

Come back when it's done - perhaps in a day or two depending on the speed of your PC. Go back to the above link, and follow each article through in configuring the packages as you need, especially samba. In fact, I'd recommend changing the swat port to port 80, this way you don't need to add :901 to the end of the address every time you're typing the IP into your web browser.

Make sure you configure everything properly, and then you're done! As long as you've set up shares according to the samba article, they can easily be password protected or user based, and you've now turned that aging PC into a useful file server!
raven27514 years ago
i jus can't get it to work, i get right to the end and reboot only to find out i've missed something, and i followed the instructions perfectly, i think my problem is caused either due to me installing on a sata drive or i have not setup the bootloader correctly, as i noticed in the handbook it mentions about keeping a note of the kernel name and adding it to the bootloader, but you never mention any of that, so i think this instructable will have to be updated.
tridecagon5 years ago
I have a PC with 2 HDDs, a good processor, maybe bad ram (I'll try to test it tomorrow), the screen gets no response. What'll be a good project for it? I was thinking an over-sized storage device accessible via Ethernet port, but so far all I read was install software and configure things on target PC.
abadfart5 years ago
i ended up using a IBM netvista with a mythbuntu backhand
berry120 (author)  abadfart5 years ago
Cool - bear in mind though that the mythtv part of mythbuntu will be a rather big unnecessary overhead (unless you're using it's tv part as well!)
well it dosnt have myth tv becaus i set it up as just a server but im putting a tuner card on it
abadfart6 years ago
sorry im going to ask a lot of questions because this is my first time working on a server 1. what is the minimum BIOS for Gentoo? 2. how do i hook this in to a network? 3. how much RAM do i need?
berry120 (author)  abadfart6 years ago
1) Nothing specifically that I know of, as long as it'll support hard drives larger than 4GB (Gentoo's minimum requirement) 2) Network support is generally very good - I literally installed a bog standard Belkin card in a PCI slot, booted it up and it recognised it straight away. Beyond that it's just installing things like SAMBA and CUPS. 3) I had 80MB in my machine and it worked fine, Gentoo's minimum requirement says 48-64 but I wouldn't personally like to rely on it working well in the lower end of that range, especially with SAMBA and CUPS running too. Hope that helped!
thanks
abadfart6 years ago
would an old system that originally ran 98 work?
berry120 (author)  abadfart6 years ago
The system I used this on originally ran 95, but it had a number of upgrades - the hard drive was originally 1GB (which wouldn't be enough, minimum required is 4GB) and it only had 16MB of RAM (but was upgraded to 80MB) If the requirements are too much, try debian - from memory the requirements for the base install of that are lower.
ah, in the days of freeski and mahjong
Not freeski, but SkiFree. And at that time I used to play Taipei. Good times... :)

But, now talking about this instructable (which I haven't actually read)... I guess Gentoo might take too long to compile on those old machines. On the other hand, most binary distros won't run on old computers.

Maybe m0n0wall could be another option for some people. I never tried it, but it looks good. AFAIK, m0n0wall doesn't even require a hard drive. Of course, if you are geeky enough and want more power, more flexibility, then install a linux distro like describe in this instructable.
berry120 (author)  denilsonsa7 years ago
It depends how you classify "too long." If you're willing to leave the machine on for a couple of nights straight, that's all it took for me. I was surprised, actually expected a lot longer. If you're running X though, then things would start to take a turn for the worse. And openoffice would probably take weeks alone. Still - if you're running a computer as old as I am, I don't think that's a wise move :) As for m0n0wall, I've personally always used smoothwall when it's come to firewalls and linux distros so I can't really comment. Firewalls are great, but if you've only got one ethernet card in your machine then it requires additional expense. Sure, they're cheap but I wanted to get something going with what I already had lying around. On the file server front, there is a version of BSD that is pretty much plug and play as far as I know, and works rather nicely. However, it wasn't plug and play with my machine, rather it complained at every step along the way. So it seemed gentoo was really the only option.
The fact that Gentoo compiles everything is bad because it will take a long time to install.
The fact that Gentoo compiles everything is good because it will work (eventually).
(oh, just a comment, I use Gentoo on Pentium III 800, which is my main machine)
this instructable might be kick black ass if you'd have some pics :-|
berry120 (author)  !Andrew_Modder!7 years ago
I would've done during the install, but I couldn't work out how, and my camera wasn't working either... I agree it would've been better, I might go and add some in later but I've been really busy lately. I've also started another instructable along the same lines as this one (hopefully with pics this time) but again I've been busy so not sure when it'll be finished.
ah