Raspberry Pi: the Perfect Home Server

Ever since the announcement of the Raspberry Pi, sites all across the Internet have offered lots of interesting and challenging uses for this exciting device. Although all of those ideas are great, the most obvious and perhaps least glamorous use for the Raspberry Pi (RPi) is creating your perfect home server.

If you've got several different computers in need of a consistent and automated backup strategy, the RPi can do that. If you have music and video you'd like to be able to access from almost any screen in the house, the RPi can make that happen too. Maybe you have a printer or two you'd like to share with everyone easily? The Raspberry Pi can fill all those needs with a minimal investment in hardware and time.

Raspberry Pi Benefits

Low cost: for $35, the RPi model B is nearly a complete computer with 512MB of RAM, 100Mb Ethernet, an SD card slot, two USB ports, audio out and HDMI or RCA video out. I've seen HDMI cables that cost more than that.

Energy efficient: hardware costs are only one component of a server's expense, because you also need to consider the energy cost to keep the device running constantly. The services needed for home use aren't going to tax the CPU much, and most of the time it will just be idling, waiting for something to do. The RPi's ultra-low power components are a perfect fit for this workload, which helps keep your power bill down. My model B unit plus external hard drive consume only 8 watts total, while the old Athlon-based box it replaced drew 54 watts at idle. Assuming 10 cents per kilowatt hour, that puts the yearly power bill for an RPi at $7 vs. $47 for an Athlon-based machine. The RPi basically pays for itself in less than a year!

Low noise: because the RPi doesn't have fans or moving parts, the only component in your final configuration that generates noise or any appreciable heat will be the hard disk. If you're concerned about noise, enthusiast sites like Silent PC Review often include noise benchmarks in their storage reviews. My experience is that any modern drive is quiet enough to avoid detection anywhere there's something else already running (such as a media center, gaming console or other computer). If your home doesn't provide a lot of flexibility for wiring options, the RPi's small size, minimal thermal output and low-noise footprint may make it possible to sneak in a server where it was difficult to justify one in the past.

Figure 1. A Compact, but Highly Capable Home Server

New opportunities: a less tangible benefit is the simple joy of trying something new! For me, this was my first time really working on a Debian-based distribution, and it's probably the first time many Linux enthusiasts will have a chance to try an ARM-based architecture.

Arranging the Hardware

For a home server, you'll need a medium-size SD Flash card for local storage. It's possible to use a USB thumbdrive for booting, but that would use up one of the two precious USB slots. The Flash storage card doesn't need to be large, but the faster the better. I chose a name-brand SD card with an 8GB capacity and class 10 speed rating. For backups and multimedia files, a large hard drive with a USB dock is a must. I chose a 1.5TB hard drive and a Calvary EN-CAHDD-D 2-bay USB 2.0 hard drive dock. This dock has a feature to run two drives in RAID-0 mode, which could be useful someday. Finally, the RPi doesn't come with a power supply, but most smartphone chargers supply the required 5v-over-micro USB. To see if the RPi was fussy about the power source, I swapped through three different micro-USB cell-phone chargers for power supplies. I tried each one for about a week, with no issues on any of the units.

Installing the Operating System

Installing the RPi operating system is covered in extensive detail elsewhere, but here are a few home-server-specific tips, roughly in the order needed.

1) Get the Raspbian "Wheezy" install image directly from http://www.raspberrypi.org/downloads, and copy it onto the SD card, using the steps listed on the site.

2) When booting the RPi for the first time, attach a keyboard, mouse and monitor. Don't forget to turn on the monitor before booting the RPi, so that it can detect the correct HDMI or composite output port.

3) The RPi has a nice "raspi-config" screen that you'll see on first boot. For a home server, the following selections will be useful:

  • expand_rootfs: resizes the default 2GB OS image to fill the rest of the Flash card.

  • change_pass: the default password is "raspberry", but something more secure than that would be better.

  • Set your locale and timezone.

  • memory_split: assign the minimum amount possible (16) to the GPU to leave as much room as possible for services.

  • SSH: don't forget to enable the SSH server.

  • boot_behaviour: turn off boot to desktop (again, to save memory for your services).

When finished, you'll be at the pi@raspberrypi prompt. The setup script can be re-run at any time via sudo raspi-config.

There are just a few more configuration items, and then the operating system is ready to go.

1) A static IP makes everything easier, so switch the network settings for eth0:


>> sudo nano -w /etc/network/interfaces

change the eth0 line iface eth0 inet dhcp to the following (modify to meet your home network setup):


======/etc/network/interfaces======
...
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
...
======/etc/network/interfaces======

2) Create a local user, and put it in the users and sudo group:


>> sudo adduser YOURUSERIDHERE
>> sudo usermod -a -G users YOURUSERIDHERE
>> sudo usermod -a -G sudo YOURUSERIDHERE

3) Update the system to ensure that it has the latest and greatest copies of all the libraries:


>> sudo apt-get update; sudo apt-get upgrade

4) At this point, you're ready to go headless! Shut down the PI:


>> sudo /sbin/shutdown -h now

Once it's down (monitor the green status LEDs on the RPi circuit board to know when it has finished shutting down), unplug the monitor, keyboard, mouse and power cord. Attach the USB storage, then restart the RPi by plugging the power back in.

5) Once the RPi starts up (again, those green LEDs are the clue to its state), you can ssh in to the RPi from any other machine on the network and finish all the configuration remotely from here on out (modify the following for your static IP):


>> ssh YOURUSERIDHERE@192.168.1.10 

Congratulations, you have a working Raspberry Pi!

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Raspberry Pi server

Damiann's picture

The Raspberry Pi is a great little machine for a variety of uses.
I bought mine at first for the novelty of it. I connected it to my old TV; it was cool browsing the web on it. After the novelty of having a PC connected to my old CRT TV, i installed RaspBMC on it and now it is a multimedia center on the old TV.

Reply to comment | Linux Journal

http://www.hdpvr.fr's picture

My brother recommended I might like this web site.
He was entirely right. This post truly made my day.
You can not believe simply how so much time I had spent for this info!
Thanks!

Power Outages

FedaykinWolf's picture

I've had a dream of making myself a Raspberry Pi server, but a couple unexpected power outages made the PI unbootable... I simply had to re-install the OS, but this kinda destroyed my want to use it as a server... Have you tested an improper shutdowns? Or, have you figured out a way around this potential issue, or is this a unique issue for me and my setup?

Thanks for keeping the dream alive ;)

FedaykinWolf

Power outage and RPi

n1zhi's picture

I'd just power the unit from a battery-sourced outlet on a UPS: uninterruptible power source. TrippLite make some very good units (I'm not affiliated with the company) at reasonable prices.

One more suggestion

Brian Trapp's picture

The read-only suggestion mentioned above is a good one, but even without that I haven't seen any corruption even at a power outage. Maybe your flash card is underperforming? One thing to check - if you have an attached, large hard drive (like I suggested for storage) the system may be doing an extended fsck at boot, making it appear unresponsive. You can confirm by attaching a monitor or by listening for hard drive activity.

readonly root file system

Rob van der Linde's picture

You might want to look into using a readonly root file system to reduce writes to the SD card. I have done something similar in the past with a USB flash drive running Ubuntu server.

I have found this guide for Raspbian that might help

http://blog.a-netz.de/2013/02/read-only-root-filesystem/

The other thing you can do is create an image of the SD card using dd when everything is running nicely, and if your system fails to boot, you can easily restore the SD card from image file.

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState