When I was building my home VoIP system I was dreaming about running Asterisk. My biggest problem was to find a small box, preferably with minimum amount of the moving parts, consuming as little energy as possible and being just powerful enough to run a few things.

There is a number of small computers out there but they all were well over $200 and most of them were too powerful for the job. And I could not get hold of Raspberry PI at that time as people were waiting for months to get their board. One day I was thinking about it and I have found an old Apple TV, the 1st generation one, on the shelf.

A quick search on Google was quite encouraging. My ATV has been already rooted and I could compile Asterisk to run it there. But, in fact, I did not want to mess with old version of OS X that ATV runs on, getting the compiler for it and possibly running into some issues compiling the features I wanted. So I have decided to approach it from another direction - getting Linux installed on that little box first and then solving the problem that definitely had a solution.

Here is a compilation of the steps I had to do to get there. One of the reasons for writing it down is to have a guide for myself that I can use if I need to do it again one day. I have tried a few different guides and none of them worked entirely as-is for me so I had to come up with this compilation.


Whatever you do, you want to be able to restore the original image. Just follow this guide to do your backup. In fact, I ended up doing it in a simpler way. Since most of the hard drive is empty and I had a big USB memory stick I just used “dd” and gzip to make an image of first 3 partitions. And I have stored the partition table in the text format. So if I need it - I can always repartition the hard drive as per this table and restore the raw contents of the partitions.

Connecting a keyboard

You will need a keyboard and a USB card reader (memory stick or something similar). Since ATV has only one USB port I would suggest to get a USB hub and connect the keyboard and the card reader to it. Actually, I used the old Apple keyboard that has integrated USB hub, that worked for me well.

Getting the picture

You can use your TV via HDMI cable or use HDMI-to-DVI adapter and connect it to your monitor.

Getting the bare bootloader

Use atv-usbcreator to create a basic boot loader on your USB memory stick.

Get netboot.tar.gz from Ubuntu

You need a network installer for Ubuntu, which you can get from here. Put it on your memory stick.

Boot from your USB drive

Just plug your memory stick into USB hub and boot. Thanks to atvusb-creator this always worked perfectly! Your keyboard is expected to work once the boot is complete.

Get the recovery image and boot.efi

Just follow this guide to extract your EFI file (boot.efi). Then download the recovery image using the link from the same guide.

Repartition your hard drive

I have done this exercise but, in fact, this was not needed at all. This guide explains what is expected to be on each partition. So, it would be enough to just download “parted” as per this guide and redo the 4th partition. In fact, you need to delete the old “media” partition and then create Linux swap and Linux native ones.

Place boot.efi and recovery image on the appropriate partitions.

Start the Linux network installer

Read this guide that explains how to use “kexec”. This is all you need to kickstart your network installer you have downloaded at the beginning. Get some coffee or beer - this will take a while.

Install Linux

Nothing really ATV-specific in this installation process. One important thing not to forget - install OpenSSH server right away so you can connect to your new ATV after reboot.

Install GRUB on the Linux partition

In my case it was /dev/sda5 since my /dev/sda4 was a swap partition.


Unplug your USB stick. When you reboot the same patchstick image will load from your hard drive.

Fix your MBR

Apparently GRUB has managed to corrupt the MBR of the hard drive during its installation. I had to follow this guide to restore it.

Final touch - get GRUB configuration right

I think the version of Ubuntu I have installed had newer version of GRUB (GRUB2) then described in all other guides. So I could not get it to boot automatically into the newly installed Linux system. After reading some GRUB documentation I was still missing some information. Reading this guide was very helpful. There is a section in the middle that explains the boot sequence in details. I have ended up creating my own grub.cfg like this:

default 0
timeout 3
title Linux
root (hd0,5)
kernel /boot/vmlinuz-2.6.24-28-generic root=/dev/sda5 ro vesa video=vesafb
initrd /boot/initrd.img-2.6.24-28-generic

And it worked!

Now I have a very nice Linux server that runs Asterisk, controls a PLM modem and does a few other neat things - all on that old AppleTV that I could not use as a media player anymore.

blog comments powered by Disqus


28 May 2012