Linux on Apple TV
If you would like to contact the moderator of this page, email: kad77 [at] awkwardtv [dot] org
Also, let's start using the Discussion Page.
- Edgar (gimli) Hucek from the mactel-linux project, and AwkwardTV contributor, has gotten the Linux kernel to boot via a custom loader-- which is itself loaded by the AppleTV boot.efi loader. gimli was the first to get Linux running on EFI Intel Macs
View the current SVN with your browser. The Linux side actively requires testing. As you will read below, the results are phenomenal so far.
Sourceforge SVN client address: https://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux/trunk/mach_linux_boot
NOTE: "mach_linux_boot" is the only code you need from mactel!
- A precompiled mach_kernel binary can be obtained from  (Modules: ). This linux 22.214.171.124 kernel was compiled on a Slackware 11.0 system and has been running fine on my Apple-Tv without any problems for days. The kernel has built-in ext3 support.
DO NOT REMOVE THIS NOTICE UNTIL AN ANSWER WITH LINKS HAS BEEN WIKI'D (kad77): We need to establish whether the official NVidia Linux binary supports PureVideo/CUDA for MPEG hardware acceleration; further we need a demonstration application that explicitly shows MPEG hardware acceleration is enabled and usable under Linux. Without hardware MPEG decoding through the GeForce 7300 Go, we are at a severe disadvantage using Linux for video display. Perhaps the video driver could be ported or reverse engineered from the original Apple TV OS (Mac OS X 10.4.7)? See these links (please add):   
The only known Linux hardware video codec acceleration is by using XvMC (for MPEG-4, only using Via chipset). The Linux NVidia binary drivers are not documented to support anything but MPEG2 offloading, so PureVideo is currently unsupported for Linux.  However, Apple TV almost certainly has hardware acceleration enabled, so that would point to the existance of non-Windows PureVideo-like MPEG-4 hardware assistance.
linux kernel 2.6.21 is up and running CentOS4.4/Trixbox on my aTV! Now where to send the patches and config? I also never had the need for the irqpoll kernel option, so that might have to do with my different .config settings. Couldn't get the mb_boot_tv to work, so I'm still using the pseudo mach_kernel boot method. (rcfa)
Could you write your installation procedure for CentOS? Upload your config to a free hosting service and post a link.
AwkwardTV Linux Project
Many of us would like to see a minimal source distribution, targeted for AppleTV and utilizing the Linux kernel, emerge with boot and kernel configs. Extras might include scripts for USB or disk image builds. Currently we will be working with gimli's Mach-O wrapper approach to bootstrapping, and this will require a MacOS X setup.
Information has been posted to the mactel wiki regarding a Darwin cross-compiler for Linux to compile the Mach-O binary. gimli reports this to work on Ubuntu Fiesty.
- 'alien' package must be installed
- Change to 'mach_linux_boot' and execute the script 'get_cross.sh'
- Move 'darwin-cross' to /opt/
- Execute 'make.sh'
- Cross-compiler download: Darwin/MacOS X Cross-Compiler for Linux (Sourced from the mactel-wiki)
It bears mentioning that we recommend a complete backup of your original AppleTV drive before any experimentation. We have a wiki page dedicated to this subject. Remember, if you pipe the dd through gzip or bzip2, the virgin drive image created should only be ~2.5gb!
Linux Installation Guides
Please add your guides here, they will (hopefully) be maintained by their authors.
beyond's Gentoo Guide
Status of this work: This is a first draft, expect a lot of changes in the coming days.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License
* Apple TV; with Hard Drive removed * A Gentoo Linux computer - any Linux PC should work, but may have some subtle differences * An Mac OSX computer * Laptop IDE->USB Adapter
Please note: many commands will require root access to the computers, please become root as needed.
Step 1: Backup your AppleTV
First connect your AppleTV HD to your IDE->USB adapter, then open a terminal. Issue the following command in the terminal:
dd if=/dev/disk1 of=/path/to/backupfile bs=1024
Please note: /dev/disk1 is the device that is associated with the AppleTV HD. This can vary based on your system configuration.
This process takes a while, so be patient, it will finish eventually!
Under Linux: First connect your AppleTV HD to your IDE->USB adapter, then open a terminal. Issue the following command in the terminal:
dd if=/dev/sdx of=/path/to/backup bs=1024
Please note: /dev/sdx is the device that is associated with the AppleTV HD. This can vary based on your system configuration.
This process takes a while, so be patient, it will finish eventually!
Step 2: Partition and format your AppleTV HD
In a terminal make use of the 'gpt' utility to delete and resize your media partition. There is a project providing an ext3 driver for OSX that you can use to create the filesystem. More details will be available soon.
Under Linux: First we must include the correct options in the kernel, type:
cd /usr/src/linux make menuconfig Select "File Systems" Select "Partition Types" Enable "Advanced partition selection" Enable "Macintosh partition map support" Enable "EFI GUID Partition support" Exit and save configuration changes, then type: make && make modules_install Then copy the new kernel into /boot and reboot. Once your system has rebooted you can repartition your AppleTV HD if you wish, using the GNU parted utility. Once you are ready to continue in a terminal run: mkfs.ext3 /dev/sdx4 (sdx4 is the partition you want to install Gentoo on, ie for me it was sdc4)
Step 3: Install the stage tarball
First we must mount the formatted partition to do so type in a terminal:
mkdir /mnt/appletv mount /dev/sdx4 /mnt/appletv
Open a browser and load: http://www.gentoo.org/main/en/mirrors.xml, and download the current stage3 tarball as well as the latest portage snapshot.
Once you have a stage3 tarball and portage snapshot, ensure they are saved in /mnt/appletv. Open a terminal and type:
cd /mnt/appletv tar -xjvf stage3-x86-2006.1.tar.bz2 tar -xjvf portage-latest.tar.bz2 -C ./usr/
Step 4: Enter the new Environment
Open a terminal and issue the following commands: cp -L /etc/resolv /mnt/appletv/etc/resolv.conf mount -t proc none /mnt/appletv/proc mount -o bind /dev /mnt/appletv/dev chroot /mnt/appletv /bin/bash env-update source /etc/profile emerge --sync --quiet
Step 5: Build a kernel
Download the vanilla 126.96.36.199 kernel from kernel.org. Please ensure it is saved to /mnt/appletv/usr/src/. In our terminal that is in the new environment type:
cd /usr/src tar -xjvf linux-188.8.131.52.tar.bz2 -OR- tar -zxvf linux-184.108.40.206.tar.gz emerge subversion svn co https://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux/trunk/mach_linux_boot/kernel . patch -p0 < 220.127.116.11-appletv.patch mv config-2.6.20-appletv linux-18.104.22.168/.config cd linux-22.214.171.124 make && make modules_install
Step 6: Configure the installation
In Linux, while in the environment issue the following commands, or substitute your own setup below.
passwd [follow the on screen instructions to set the root password...] emerge syslog-ng vixie-cron slocate dhcp rc-update add syslog-ng default rc-update add vixie-cron default dd if=/dev/zero of=/swap bs=1024 count=1000000
Now we must edit several files, first /etc/fstab:
/dev/sda4 / ext3 noatime 0 1 /swap none swap sw 0 0 /dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro 0 0 #/dev/fd0 /mnt/floppy auto noauto 0 0 # NOTE: The next line is critical for boot! proc /proc proc defaults 0 0 # glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for # POSIX shared memory (shm_open, shm_unlink). # (tmpfs is a dynamically expandable/shrinkable ramdisk, and will # use almost no memory if not populated with files) shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
Then we must edit /etc/modules.autoload.d/kernel-2.6 to add the following lines:
snd-hda-intel snd-mixer-oss snd-pcm-oss
Edit /etc/conf.d/net to include the following line:
modules=("dhclient") Then run: rc-update add net.eth0 default exit umount /mnt/appletv/proc umount /mnt/appletv/dev cd umount /mnt/appletv
Disconnect the apple tv drive from the computer at this point.
Step 7: The Kernel Wrapper
In OSX: At this point we must build the kernel wrapper provided by Gimli at Mactel-linux. First copy bzImage from /mnt/appletv/usr/src/linux-126.96.36.199/arch/i386/boot/bzImage to your OSX computer.
On the mac, first download and install subversion, one implementation is available at metissian.com. You must also have Xcode installed, which is available for free from Apple.
Open a terminal and type:
svn co https://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux/trunk/mach_linux_boot mach_linux_boot cd mach_linux_boot make
At this point copy the bzImage file from above into the mach_linux_boot folder. Then run this command:
From here we must copy the file mach_kernel to the osboot partition on the apple tv drive. Delete the mach_kernel.preload from this partition while you do this.
In the osboot partition, edit the file com.apple.Boot.plist in folder System/Library/Components or in /System/Library/CoreServices , the contents should look like:
<key>Background Color</key> <integer>0</integer> <key>Boot Logo</key> <string>BootLogo.png</string> <key>Kernel</key> <string>mach_kernel</string> <key>Kernel Flags</key> <string>root=/dev/sda4 irqpoll</string>
At this point you can unmount the AppleTV drive, install it into your AppleTV and boot it up! Congratulations you are running Gentoo on your AppleTV!
The original guide comes from beyond's site, used with permission.
arodd's Basic Gentoo Install Guide
Basic Instructions (Assuming you are on OSX and have Xcode Installed on an Intel Mac, and are installing to the internal AppleTV HD)
The guide also assumes you are using Gentoo Linux OS (for x86) http://www.gentoo.org/doc/en/handbook/handbook-x86.xml
You need to use a LiveCD that supports EFI GPT partition tables.
The Ubuntu InstallCD does. http://www.ubuntu.com/getubuntu/download
The best way to do this step would be to hook up the atv hd to your computer running OSX and create the proper gpt partition for linux and format it as ext3.
More detailed instructions for this will be included later.
The basic rundown would be to make a backup image of the media partition data. Then use gpt to kill the 4th partition on the atv hd. Create a new media partition that doesn't use up the rest of the drive and set as type hfs. Then make a 5th partition as type linux to fill the rest of the drive. Then recover the data to the Media partition
You will need the ext2/3 driver for OSX installed http://sourceforge.net/projects/ext2fsx/ you will then have the tools to format the partition as ext3 and access it from OSX.
newfs_ext2 -j /dev/diskXs5
Boot to the Ubuntu Live CD and then reach the graphical terminal.
sudo su This will probably be hda5/hdb5/sda5/sdb5 or something similar
apt-get install subversion
mount /dev/deviceforatvhd /mnt/gentoo
dd if=/dev/zero of=/mnt/gentoo/swap bs=1024 count=2097152 Creates a 2GB swap file on the root partition
tar -xjvf linux-188.8.131.52.tar.bz2
svn co https://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux/trunk/mach_linux_boot
patch -p0 < mach_linux_boot/kernel/184.108.40.206-apletv.patch
cp mach_linux_boot/kernel/config-2.6.20-appletv linux-220.127.116.11/.config
Start at 5.b on the Gentoo Handbook and continue to the portion before you emerge gentoo-sources 7.b and then continue on below. Make sure you are in the chrooted environment
Add any other features that you may want. Probably not a requirement. Personally I moved some of the things from module to built in. File System support in particular this way you don't need to load a module for hfs/hfs+
make all && make modules_install
Wait for compilation to finish.....and then cleanup
cp arch/i386/boot/bzImage ../mach_linux_boot/
mv mach_linux_boot /
ln -s linux-18.104.22.168 linux
ln -s 22.214.171.124-appletv 126.96.36.199
Seem to have missed a patch somewhere so it's looking for both folders when you load a module
Now the bzImage file is located in /usr/src/linux-188.8.131.52/arch/i386/boot/bzImage as well as in the mach_linux_boot folder which we will copy to OSX later. Continue with the Gentoo Handbook from 8.a. all the way up through 9. Make the fstab look similar to below.
/dev/sda5 / ext3 defaults,errors=remount-ro 0 1
proc /proc proc defaults 0 0
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
/swapfile swap swap defaults 0 0
Skip all of the bootloader stuff in 10. You can follow 10.d to unmount filesystems etc. Reboot back into OSX
Open Terminal and begin the OSX portion of the mach_kernel loader compilation.
Since the svn-client in fink doesn't support ssl the easiest way is just to cp it from the ext2 partition.
sudo cp -Rv /Volumes/linuxatvpartition/mach_linux_boot /Users/you/Make sure that your bzImage file is located inside this folder...If not copy it here from your linux partition.
Now you have a mach_kernel loader with a linux kernel image enclosed. The ideal method would be to store this on the Media partition alongside boot.efi/com.apple.Boot.plist copied from the OSBoot partition. Modify com.apple.Boot.plist to look similar to below
<key>Background Color</key> <integer>0</integer> <key>Boot Logo</key> <string>BootLogo.png</string> <key>Kernel</key> <string>mach_kernel</string> <key>Kernel Flags</key> <string>root=/dev/sda5 rootdelay=10 irqpoll</string>
Needs Testing/More Documented work
root= may need to be changed to whatever partition number your ext3 partition is at.
The only problem was that I was only able to get it to boot the kernel from the OSBoot partition by removing the atv mach_kernel.prelink from the root directory and customizing the com.apple.Boot.plist in /System/Library/CoreServices/com.apple.Boot.plist. That didn't allow me to dual boot. There is no reason why we shouldn't be able to do the same from the Media partition and swap between atvos/linux and eventually atv/osx/linux, I just haven't got it working yet. In order for it to boot to a specific partition you need to use the bless command either from the ATV via ssh or via an Intel mac. Example...
bless --device=/dev/disk0s4 --setBoot --nextonly
* If you experience slow wired ethernet speed, try adding the kernel flag no-hlt after irqpoll
Much of the AppleTV's hardware is supported natively under the Linux kernel. In this section, we will be expanding on the Linux driver details.
Intel CPU Core
- Speedstep functionality - WORKING
GeForce 7300 Go (NV40) Note: framebuffer fixes in SVN as of April 6, 2007 - please recompile
- Official NVidia binary driver works without modification. Full 3D and framebuffer acceleration.
- OSS NVidia driver works without modification (also provides acceleration)
(==) NV(0): Write-combining range (0x10000000,0x4000000) (II) NV(0): Using XFree86 Acceleration Architecture (XAA) Screen to screen bit blits Solid filled rectangles 8x8 mono pattern filled rectangles Indirect CPU to Screen color expansion Solid Lines Scanline Image Writes Offscreen Pixmaps Setting up tile and stipple cache: 32 128x128 slots 32 256x256 slots 16 512x512 slots
- HDMI - WORKING (DVI tested)
- Component working using a single cable (chinch cable at the green video output connected to the yellow video input of my old 4:3 CRT-TV). Colors are fine and so you don't need a video converter box (as suggested in many forums). Tested using the binary nvidia driver and this config:
Section "Device" Identifier "Card0" Driver "nvidia" VendorName "nVidia Corporation" BoardName "Quadro NVS 110M / GeForce Go 7300" # Option "MetaModes" "1680x1050" # Option "ConnectedMonitor" "DFP,TV" Option "TVStandard" "PAL-B" Option "UseDisplayDevice" "TV" EndSection
Intel HD Audio
- HDA-Intel driver recognized by default
- Analog RCA - WORKING (see http://forum.awkwardtv.org/viewtopic.php?f=23&t=167&hilit=&start=70)
- Optical SPDIF - WORKING
- HDMI - apparently NOT WORKING
- mactel-linux driver recognizes it - untested otherwise
- first signal from apple remote is somewhat recognized. Any following signals are not reported. After reloading usbhid module another signal is reported (using cat with /dev/input/by-id/usb-Apple_Computer,_Inc._IR_Receiver-event-ir)
patch appleir.c to include the AppleTV IR USB id (#define USB_DEVICE_ID_APPLE_TV_IR 0x8241) in the same way as USB_DEVICE_ID_APPLE_IR and it will work.
- Apple_TV_Linux_IR_Howto details the userspace method.
Broadcom BCM94321MC wireless
- USB booting works when you disable ehci-hcd in kernel
- possible to boot Linux from USB Flash memory?
- USB HID working (keyboard, mouse), but not with ehci-hcd
- USB Storage working (tested with usb memory stick), but not with ehci-hcd
Our components wiki has further information about the specific chips involved.
Barebones Distro Notes
Our preferred base distrubutions:
- Lunar Linux 1.61 A full source based distro, customizable and friendly.
- ttylinux 6.0 A micro distro (8MB w/kernel)
There are a few Linux distributions specialized for Media Center usage:
Some useful components:
- elilo bootloader 3.6 (stable)
- The Linux kernel 184.108.40.206 (recent)
- NVidia binary driver (latest)
- BusyBox 1.4.2 (stable)
- MatchBox Window Manager
- XOrg X11R7.2 We would prefer a lightweight X alternative or optimized/minimal X11 build. KDrive is framebuffer only.
Other external sources:
- Installing Linux using atv-bootloader (Ubuntu Gutsy, Gentoo, Mythbuntu, MythDora, KnoppMyth, miniMyth, LiveXBMC)
- ATV/Gentoo Wallpaper BigBaconAndEggs
April 5, 2007 dmseg output: (from gimli @ mactel)