Sunday, December 28, 2008

The Perfect Home Server: MSI Wind Desktop

Introduction

For a long time my desktop computer running Arch Linux performed double duty as a home server. The Arch computer isn't very stable, and it has a Core 2 Duo processor, which is overkill for a server. As a result, I decided to set up a seperate home server for the following uses: ssh gateway, music server (mpd + icecast), IRC client, downloading server and backup server. The requirements: stability, low power consumption and low noise.

Hardware

The MSI Wind Desktop is a bare bones system, based on the Atom chipset. All of the hardware works perfectly under Linux, making it a great home server platform. It includes the following:
  • Atom 1.6 Ghz CPU
  • 2 SATA slots (3.5" and 5.25")
  • Gigabit Ethernet
  • Intel 945GC integrated graphics, with VGA output
  • Realtek ACL858 8 channel audio
  • SD/MMC/MS/XD card reader
  • Internal Compactflash slot
  • Mini PCI slot
In addition, I added a 750GB hard drive for file storage, a 8GB Compactflash card for the operating system, and 1GB RAM. The total cost is around $250.

The Atom chipset is very effecient, so the MSI Wind only has a single case fan for cooling, resulting in a very quite machine.

The hardware installation was simple. The only annoyance: I had to unscrew the motherboard to install the Compactflash card.

Software

Operating System:

I decided to use Debian Lenny stable, (Release Candidate 1). I also briefly considered CentOS, but my love of apt won out. Even though my goal is stability, I couldn't bring myself to use the current Etch, since it's going to be replaced soon (I hope). This a simple headless server, so I only installed the basic server package set. Since I didn't buy an optical drive, I used a USB CD drive. It's also possible to install Debian from a flash USB drive - Debian has an installer for this here.

To minimize noise and power consumption, I installed Debian to the Compactflash card. Since flash memory has a limited write life, I was worried that this might be a mistake. However, after researching the issue thoroughly, I couldn't find a single report of this happening in actual practice. All the same, I took the following precautions to avoid excessive writes:
  • No swap partition
  • ext2 for the OS partition (journaling file systems like ext3 need to write frequently)
  • In case of failure, all the important OS files are backed up to the hard drive daily with cron and rsync

I created a single ext3 parition on the hard drive. Since the hard drive is not in constant use, I installed hdparm, and set the hard drive to spin down after 10 minutes of idle time with hdparm -S 120.

In addition to the basic debian installation, I added some of my favorite command line utilities: screen for managing multiple terminal screens, nmap and iptraf for network troubleshooting, vim for editing text, irssi for chatting on IRC, rtorrent (and wget) for downloading, and elinks for basic web browsing.

SSH:
To improve security, I disabled password authentication, and root SSH access. Using public key authentication prevents bruteforce attacks. It also allows you to login in without a password/passphrase, but this must be used carefully. I also forward port 22 from router, to allow outside access

Backup Server:
To automatically back up my desktop, I use rsync with ssh:
  1. I created a second user on the server called "rbackup". On my hard drive, I created a backup directory, group owned by "rbackers", which includes my regular user and "rbackup". The "rbackup" user has an ssh key with requires no passphrase, which is necessary for automating backups.

  2. On my desktop, I set up a simple backup script using this rsync command: rsync -avz --exclude-from excludefile.txt -e "ssh -i $KEY" $BDIR $USER@$SERVER:$RPATH |tee backuplog.txt
  3. Using cron, the backup script is run twice a day.

  4. In addition, I manually run a second script occasionally that syncs with deletion. It does a dry run first, which I look over for important files (rsync -avzn --delete --exclude-from $EXCLUDES -e "ssh -i $KEY" $BDIR $USER@$SERVER:$RPATH|tee synclist.txt)

Of course, there are many backup solutions that I could of used: amanda, zmanda, bacula, rsnapshot, and more. I decided that for my purposes, something simpler would be best.

Streaming with MPD and Icecast
In my opinion MPD (Music Player Daemon) is by far the best way to play music in Linux. You can can use multiple front ends to control it, even over a network: GMPC or Sonata from Gnome, Pitchfork over the web, ncmpc or ncmpcpp from the command line. ncmpcpp is my favorite, even on my desktop. MPD can play to multiple outputs, including sound cards outputs, and streaming servers. In this case, I set up outputs for Icecast and ALSA. To allow streaming from anywhere, I forward port 8080 from my router to the server.

Conclusion

The MSI Wind is a perfect home server. Combined with Debian, it has been extremely stable: I've only rebooted for kernel updates. There's something magical about booting a computer, without the hard drive spinning up. Considering the the price of a 750GB external hard drive is around $175, paying about $75 more to get a full blown computer and network storage device is a great deal. The Atom chipset is perfect for this. Right, there are only a couple of Atom desktops available: the EEE Box from Asus, which is too small to use with a 3.5" hard drive, and more expensive. There's also the Shuttle X27, which is a nice option, but lacks the Compactflash slot, and it costs a bit more. It's a shame that there's not models aimed specifically at light server use out there, but the home Linux nerd market is pretty small.

No comments: