The author of this tutorial should not be held responsible for any loss of data or hardware that one may encounter by following this tutorial. You have been informed.

We’re developers! We have projects, a lot of projects. We don’t want to store the old ones on our dev machine, because you know, storage and organizing stuff is important. Oh, who am I kidding, go rent yourself 20TB of space at Amazon, you’ve earned it.

But if you don’t want to do that, what can we do about it? A simple answer would be to get that crappy old machine you used to develop stuff in 9th grade and make a file server out of it.

Whether you’re archiving your old projects, storing images of your ex or just downloading huge collections of cat videos, you’re in a point in time when your information is your main concern. You may have a large fast drive but that doesn’t mean you can keep all your information on it.

Sure you can set up a cloud environment or an external hard-drive but that doesn’t mean you should. What if the internet goes down, or you lose the hard-drive and besides that who doesn’t love SSH and its ultimate supreme powers.

That’s why in this “short little” tutorial, I’ll show you how to set up a basic file server using some basic knowledge of Linux commands, some magic and a lot of patience. Follow the steps bellow in order to complete this awesome “little challenge”.

Step 1 – Setup the USB drive

Get a hold of an old USB drive with at least 2GB of free space on it and a crappy old machine that is held together by duct-tape and your hopes and dreams. You already have them? Awesome. Plug in the USB drive in your computer (not your lame excuse of a machine) and let the awesomeness begin. We need to prepare for the setup ahead.

Download the latest LTS of Ubuntu in the form of a mini version. You can use any other distro, but for this tutorial I’ll use Ubuntu 14.04 (I like to stay up to date). You can get one here or choose from the list here.

After that, you need to download an app that allows you to set up the ISO on the USB drive. Due to the fact that it’s a minified version of the original ISO, it doesn’t have all the crap that the original Ubuntu has, it’s just basic Ubuntu. You can use this app for example, UNetbootin, to set up the ISO on the USB drive. Follow the steps bellow to write the ISO on the USB drive.

  • Open up the app.
  • Select the Diskimage radio button.
  • Choose the Ubuntu mini ISO you downloaded previously.
  • Choose the USB drive.
  • Click ok.
  • You’re awesome!

After you finished writing the ISO on the USB drive, unplug it from your computer, and plug it into the machine you want to set up the file server on.

Step 2 – Install Ubuntu, the mini version

Now comes the fun part.
After you plugged the USB drive into your crappy machine, enter the BIOS setup and set the USB drive as the first boot device, save and boot from it. I can assume you already know how to do this.

  1. When the Installer boot menu comes up, select the first option, Install.
  2. Next choose the language, followed by selecting your location.
  3. You can choose to configure your keyboard or auto-detect it. In most cases you let it auto-detect by choosing No.
  4. The next step will ask you to set a hostname for your server. This name will identify your system on the network so you can access it more easily. Set a simple, recognizable name, like “the_google_server_for_ads”, because it’s a local network, you don’t need to worry about anyone making fun of it.
  5. The following step allows you to choose the mirror you want to download the updates /required files / libraries that the OS may need. Choose one based on your current location.
  6. Leave the PROXY field blank, because you’re on a local network. After the installer gets all the files it needs from that mirror, head over to the next step.
  7. The next screen will prompt you to reformat the hard disk. Let’s assume that you are going to use the whole hard disk, just select “Guided – use entire disk”. If you are not going to do that, you can select “Manual” and configure the partitioning accordingly.

Choose Yes to confirm the settings.

  1. Let the installer do this job.
  2. Next, choose a username and password for the new machine and then choose if you want to encrypt your home folder or not.
  3. Again, you let the installer do his job, because he’s a good installer and he knows his place.
  4. Do you want security updates installed? You sure do.
  5. The next step asks you to select the software you want to install. Select Ubuntu Server.
  6. You can install the GRUB loader on the master boot record.
  7. Unplug the bastard from the machine and reboot the machine.
  8. Et voilà! You have a new Ubuntu machine set up. You can now login.

Step 3 – Configuring Samba

It was fun until now, right?
Alright, but you need to allow access to this server from the network. How do you achieve this?

You use Samba. It allows you tho share files between Ubuntu, Windows and Mac with no problem.

Run the following commands, on your newly installed Ubuntu server machine, to install Samba:

sudo su

Enter your root password.

apt-get install samba

This will install the Samba server on that machine.
After that you need to configure it. Run the following commands:

mkdir /home/%YOUR_USERNAME%/Public
chmod 777 /home/%YOUR_USERNAME%/Public 
cd 
gedit /etc/samba/smb.conf

You can use any editor you want, of course.
The first thing you need to enable is the Windows support. Find the following line in the Global section and set it to yes.

[global]
  wins support = yes

After that head over to the end of the file and add the following lines. Remember to replace %YOUR_USER% with your actual username.

[Public]
  comment = Public Folder
  path = /home/%YOUR_USERNAME%/Public
  browseable = yes
  read only = no
  guest ok = yes
  guest only = yes
  create mask = 0755

Safe the file and reboot Samba using the following commands:

restart smbd
restart nmbd

That’s it for this step. Basically you should already see you machine on the network and perform actions inside that folder. Of course you can modify the options in the Samba config file as you please, but be careful before you do that.

The last steps are optional and should be followed only if they are actually needed or if you want to have some fun and learn something useful.

Step 4 – Configuring SSH

Since it’s a local network and you don’t actually go out into the world with that server you can install OpenSSH, so you can manage it from your own computer instead of using a keyboard and a monitor connected to that machine.
On the server run the following command:

apt-get install openssh-server

and you’re done with the server, SSH is now installed. Now back on your own machine! If you’re using Ubuntu or Mac run the following commands in your Terminal.

You need to generate a key that allows you to ssh into the server machine. Run the following command to generate one.

ssh-keygen -t rsa

If you want to avoid the login you can set up a configuration file. In your Terminal run:

cd /home/%YOUR_USERNAME%/.ssh/
nano config

add the following line to the file and then save it.

User %THE_USERNAME_YOU_SET_ON_THE_SERVER%

You can now connect to your server via SSH using the following command and the correct IP address, that your server has on the network. You can find this, by visiting your Router dashboard or by heading over to the last step of this tutorial.

ssh 192.168.1.xx

Head over to the next step for more useful commands that you can use on your server.

Step 5 – Bonus Commands

Besides the commands I have already mentioned in this post a while back. Here are some bonus ones that you can use to scan your network for other computers and to find your own IP.

First you need to install a package that allows you to do that. Run the following command:

apt-get install arp-scan

After that, you can scan the network using the following command, if the machine is on a WiFi network:

arp-scan --interface=wlan0 --localnet

or just

arp-scan -l

if it’s an LAN connection.

Another useful command that is used to configure the system’s kernel-resident network interfaces is the following:

ifconfig

And that was the end of this step.
Congratulations! You have finalized this tutorial! You are an awesome human being! :)

I hope this tutorial was useful, because it was fun for me to write and to experience it. I spent a whole day trying to get this right on the first try. I had a really crappy old machine with only 256Mb of RAM, that for some weird reason didn’t die on me.

Please, by all means correct any mistakes I might have made in this tutorial and please share your experience on this topic. What configurations do you use? Leave a comment below.

Until next time, code long and prosper!

Stefan