Debian on the AppleTV

It's hardly a first, but I did find some of the information out there a bit spread out. So, just incase I need to go through this again, I figured a 'blog post might be interesting - doubly so as I've not really got anything interesting from work, that I can blog about at the moment!

So, a bit of background. The AppleTV (ATV) is basically a dumb x86 PC - Pentium M 1GHz, 256MB of RAM, 40 or 160GB PATA HDD, 1x USB 2, 1x IR receiver, 10/100Mb ethernet, 801.11n Broadcom WiFi and a Nvidia Geforce GO 7300 - all which uses about 17W of power in a fairly compact and quiet, form factor. What I hadn't banked on was the very retarded power supply. I knew that the ATV wasn't able to power off, but I assumed that was a software thing. Oh no. The actual power supply has no concept of switching. It's either on or off. Which is slightly annoying.

The whole "hacking" process is largely taken care of - a bunch of enterprising invididuals have got it running, over the course of several iterations. The most recent is the efforts from the ATV-Bootloader team, who have basically built a small recovery image, which translates some of the EFI structures into BIOS compatible (allowing unpatched kernels to run) and has a very cut down Linux installation which then chainloads (using kexec) another Linux kernel. The really awesome thing is that these guys have made some nice tools to stream line the efforts if you want the ATV OS and Linux to co-habit. I didn't want this particularly.

So first thing first was the old hard disk was removed and a new one was prepared under my desktop install of Linux, via a USB to IDE converter, using the instructions on the ATV-Bootloader project wiki. Pay close attention to the requirements for a patched parted.

Next I used debootstrap to install a basic Debian (squeeze) system into /dev/sda4 (ATV-Bootloader sees all drives as /dev/sd*, where as when you boot into a kexec'ed kernel they will be seen as /dev/hd* - this confused me for a few minutes - not something you want when you're scrabbling around at stupid o'clock in the morning). At this point I then chroot'ed into it and used apt to install a kernel, but no bootloader. Since the ATV-Bootloader uses kexec all you need to do is have a valid one of the following: mb_boot_tv.conf, menu.lst (grub), syslinux.cfg (ISOLinux), or kboot.conf. Having played with grub files quite a lot I thought that I knew the syntax well, but do you think I could get it to work with a grub file? No. I ended up whimping out and using a mb_boot_tv.conf (popped it into the root of the Linux partition) which is a lot simplier[1] and is infact the first file searched for (so its slightly faster to boot). If you don't fancy that then check out boot_linux.sh from the ATV-Bootloader trunk to see all the options and example configs (in-line comments). The only other things you need to remember are the usual when debootstrapping - create a valid /etc/network/interafces (man 5 interfaces, if you're unsure), make sure udev numbers your network cards correctly (/etc/udev/rules.d/70-persistent-net.rules), and of course your root password. Exit, reboot and hey presto, you should be into a very basic Debian install.

My next annoyance was the flashing LED. By default it flashes orange to tell you that its booting, and then the ATV OS would reset it to a white light. Thankfully a great chap by the name of Peter Korsgaard has written a tool (available from git and here - note needs to be compiled) called atvtool to control the LED and the fan. It's a little basic and doesn't play well with lircd at the moment (you can set atvtool to release the controller back, at which point lircd needs to be restarted), although I'm hoping to have a poke and understand why and hopefully fix this.

WiFi is also fairly important to me since I'm going to use the ATV to replace my WRT54G bridging 2 networks here. Sadly the only real options seem to be using ndiswrapper or the Broadcom-STA drivers. I opted for the Broadcom-STA and things are going well, with no issues at present - the only special thing I did, for my own brain, was to rename the adapter to wlan0 (again, udev persistent-net.rules).

From here on out, if you're running headless, everything should be working like a dream. At this point I elected to install the nvidia kernel module only to see if I could get anything useful from lm-sensors, but there wasn't much luck on that front. if you're planning on using the ATV as a media center or with a monitor/TV, then you'll definitely need it.

What does this leave you with? A low power, almost silent, fairly capable machine to run part of your network. The only sad thing, in my eyes, is the limitation of a single USB port. From here you could run forked-daapd to share your music, any of the several network file systems, DHCP, DNS, you name it. Just watch the memory usage - don't forget that there's only 256MB of RAM to play with.

[1] Vaguely what my mb_boot_tv.conf looks like - note the /dev/hda4 instead of /dev/sda4. #try-net-boot kernel /vmlinuz append ro root=/dev/hda4 initrd /initrd.gz

Collected droppings from other citizens of the web

Or some interesting links, if you'd rather be polite. I apologise in advance for those who might have already seen some of these links already appear on planet sysadmin.

  • Visualizing DTrace is an interesting and amusing talk from Bryan Cantrill at this year's LISA conference. Take the title with a pinch of salt as he also delves into the infamous Shouting in the DataCentre video and a whole load of other intersting things.
  • SysAdvent 2009 has just started. Last year's was great, this year should be just as good.
  • Robert 'RSnake' Hansen has posted an informational video on DNS Rebinding, and using it in conjunction with session pinning. Worth watching if you're a system or coding guy.
  • If you're into your metal then I can recommend checking out Maylene and the Sons of Disaster. I saw them last weekend at the O2 Academy in Bristol, along with Everytime I Die, In Flames (who pulled a lucky guy out of the crowd to film from the stage) and Killswitch Engage. All were amazingly awesome, but Maylene I'd not come across before. They had a great set, extremely crisp sound (in fact the best of the gig, despite the other bands being arguably more experienced). If you've got a chance to see the remaining bits of the Taste of Chaos tour, then do so.
  • If you run a business in the UK watch out for the VAT switch back on Jan 1st 2010.
  • Microsoft are running a R2 Haiku competition. You might be able to grab a home entertainment system complete with Xbox. They don't exactly stipulate that the Haiku has to be Windows Server orientated, but it's probably expected!

Not your usual 0-day?

My feed reader just picked up a new article over at ISC about a new 0-day for Linux. You should go and read it now, because it's fairly different from most other exploits and comes from fairly innocuous looking code.

Not being a real programmer (I'll never call myself a real programmer - I hack together code, but it's almost never elegant) things like this always fascinate me.

IPv6, IPv4, and ARP on Xen for VPS

If Xen is your thing, Cory von Wallenstein's relatively recent article on IPv6, Ipv6, and ARP on Xen might be of interest to you.

I'm unsure if his patches have been merged into the main Xen source, but it's still an interesting read and useful if you're wanting to secure Xen domU's, or experiment with IPv6.

Us childish? Never...

It seems that the php.net website has implemented some soundex-esque system. It doesnt seem to be have any filtering on it at all, so you can get some rather interesting results;

php.net/cunt -> php.net/count
php.net/fuck -> php.net/faq
php.net/dildo -> php.net/delete
php.net/nude -> php.net/newt

I'm so tempted to google bomb at least one of those, the childish person that I am.

I apologise for anyone who I've offended with rude language, and hereby incriminate Theo as the source of said childishness.