pesartain.com

where I remind myself what I've accomplished.

HTPC Server on Ubuntu 9.10

Background

This is the convergence of two separate PC installations into one: an HTPC and a home server.

HTPC mark 1 was a MythTV install on a dedicated box. It didn't work so well, so I tweaked and adjusted and installed Freevo on the same box. That was mark 2.

The home server started life as a different dedicated box and a mirrored raid install. Two 640GB disks acted to provide 600GB of storage for media, files and a way in to my home network from the outside world.

Of course, I didn't keep anything sensible on the server (ie: my own files), so being able to access my home network from offsite was less than useful.

Enter mark 3 of the HTPC and mark 2 of the server.

The original brief was: a silent always-on HTPC server. Network-addressable, remote + TV controllable.

  • Energy-conscious hardware (silent where possible)
  • Always-on file/web/media-server (RAID etc)
  • Media-center (HDMI output, optical drive read, etc)

The reality was a bit of an adjustment from the brief. To buy up the necessary parts from scratch would cost around £750, and I'd end up with two extra PCs, which would need recycling or otherwise selling.

Hardware

After dismantling all of the PCs I own, and one I don't (2x AMD64s, 1x Athlon 1.4GHz, 1x Pentium4 3.0GHz, 1x AM2), I discovered that only one of these has enough SATA sockets for 4 hard drives. Needless to say it was the one PC I didn't own that I needed.

Purchasing four 1TB drives would give me more space, but linearly in cost to purchasing two more 640GBs, and again would leave me with 'wasted' hardware. I stuck to the 640s and got another two.

The one area I didn't want to skimp on too much this time around was case. I settled on a SilverStone LC20B-M, which would give me enough room inside to squeeze a standard ATX setup, but not look so jarringly out of place in the living room.

The final cost was about £220 for the case (£120) and two extra hard drives (2x £50), which should be easily offset against my electricity bill by reducing the amount of computing hardware that's on at any given time.

1x AMD AM2 dual core 1x Asus M2V AM2 motherboard 1x XFX GeForce 7600GT (PCI-E) 4x Western Digital WD6400AAKS 640GB SATAII 7200rpm 16MB Cache 1x SilverStone LC20B-M

After assembling the pieces, the case was pretty packed and the hard drives were generating significantly more heat than I expected, so I bastardised some of the old cases to get two 8cm case fans into the hard drive enclosure and one at the back as an exhaust fan. It's a far cry from silent, but it's not heating up the case (!) either.

Preparation

1x Ubuntu Server 9.10 disk.

Server

After a lot of tidying, deleting and shuffling, I managed to move all 300GB of existing files off of the old server, and onto a myriad of other hard drives, leaving me with 4 blank 640GB drives ready for installation.

The previous partitioning of drives was convoluted, complicated and confusing. This time around I took the easy option: two major partitions, one for OS one for data. Both using software raid, I hooked the OS partition (~25GB) up to a mirror (raid 1), and whatever was left got turned into the data partition using distributed parity (raid 5).

HTPC

The installation was mostly done on a monitor in the usual fashion, so very little was really required from an HTPC perspective. Having had a demo of XBMC from R^3 in Scotland, I was suitably impressed to investigate further. Boxee seemed like it was aimed primarily at online streaming, rather than management of a local repository, and while Freevo was fun, I've not got the time to go through and set it all up manually again.

Installation

It's Ubuntu. It installed. Using the server edition, the installer is in glorious text-mode, which makes this Slacker quite happy.

Server

FreeNX

SSH is excellent, but sometimes it's nice to have some buttons to click.

Follow the instructions on https://help.ubuntu.com/community/FreeNX. Add the python app for adding a repository, then add the FreeNX repo. Run through the NX setup, test that it works so far, then go back and change the default SSH keys for custom keys. Import the custom keys into your NX client and re-test.

Multiple SSH daemons

Debian init scripts are significantly longer than Slackwares, but the concept is the same: duplicate an init script that runs a second instance of sshd, using a different sshd_conf file, then ensure that init script is run at start up.

I use this to lock down an externally accessible SSH port by user - ensuring that there is only one entry point to my local network.

Email on SSH login

Because I'm paranoid, I also would like to be alerted every time someone logs in on that user (referred to as Alice from here on out).

I add .bash_startup into Alices' home directory, and make sure that's sourced from ~/.bashrc. .bash_startup contains the code from http://forums.fedoraforum.org/showthread.php?t=220653. They use ssmtp, but I use msmtp. The result is the same. You hand over a SMTP username/password and the various other ports and configuration for your SMTP server (I'm using Google's own), and it sends mail.

Lock down bashrc and bash_startup by assigning appropriate permissions and ownership, so would-be hackers can't disable your mail infrastructure on a first pass, ready for something nefarious on the second pass.

The major downside is that the configuration file does contain my email username and password in plaintext, and must be at least readable by Alice. I'm not sure precisely what the solution to this is, bar running your own SMTP server.

HTPC

XBMC

Follow the instructions laid out on http://wiki.xbmc.org/index.php?title=HOW-TO_install_XBMC_for_Linux_on_Ubuntu,_a_Step-by-Step_Guide. Run xbmc-standalone and move on.

xorg

We have a widescreen TV which requires a couple of tweaks in the config.

Section "Monitor"
  Identifier "Samsung0"
  VendorName "Samsung"
  ModelName "LE32A436"
  ModeLine "1360x768@12li" 85.50 1360 1392 1712 1744 768 783 791 807 interlace +hsync +vsync
  ModeLine "1360x768@60" 85.5 1360 1440 1552 1792 768 771 777 795 +hsync +vsync
  HorizSync   49.02
  VertRefresh 50.0 - 150.0
  Option "DPMS"
EndSection

Just don't forget to adjust the TV settings to 16:9, not 4:3!

Once you set the screen res to 1360×768 and ensure the TV is outputting 16:9, it should Just Work™.

lirc

apt-get install lirc and follow the instructions. The SilverStone comes supplied with a built in iMon VFD and lcd panel, which is run from USB. The remote is an iMon PAD, which allowed mouse-control before even installing lirc, but after installation provides mobile phone-style text input, and the ability to switch between key mode (normal remote) and mouse mode (navigate using a mouse cursor with left and right click).

The power button even seems to turn on and turn off the box properly. It's magical.

Auto XBMC startup

Add a dedicated user (I called mine xbmc), and set up permissions appropriately. Ensure they're added to the cdrom and plugdev groups to allow XBMC access to the drives and hotplugged USB devices.

So many different options for autologin using GDM, but the easiest was found at http://www.perturb.org/display/GDM_AutoLogin.html and requires just adding three lines to /etc/gdm/custom.conf:

[daemon]
AutomaticLoginEnable=true
AutomaticLogin=xbmc

The XBMC installation appears to come complete with an XBMC session, which doesn't run a window manager; just XBMC. After you've booted up and logged in manually with the new user using the XBMC session, it should remember you for next time. Power cycle to test.

Conclusions

Setting up XBMC on Ubuntu is easy. So far I've not found anything that doesn't have a package I can use, which makes the whole process very quick. I can still stick my oar into configuration files, and I don't even have a lot of the graphical configuration tools installed. apt-get is something that I have quickly grown to love, and it is nice to concentrate more on the task at hand than on trying to set up the PC for the task.

Given the time again, I could probably go from a bunch of bits, to a completed and running system including all the extras listed above in around 90 minutes.

Also, the case looks awesome.

Who am I? I answer to Piete or Pieter and I try to be more than just my job title.

Browse my blog, read about me, or listen to my music.