Part 2 – Preparing the Crystalbuntu USB Thumb-drive With Linux Mint
Update (April 2012) All videos are now done with Linux Mint so that they match the guide. Also – Fixed a few VERY embarrassing typos in the commands… SORRY!
The process to install Linux on an Apple TV is actually quite simple, but things get a bit more complicated when you also want to remove the hard drive from the Apple TV. This guide will include everything you need to do to get up and running with no hard drive. This guide will also include a number of optional configuration changes that may be very useful to those who need them such as adding a static IP address, DNS address and later some advanced XBMC settings.
Also, since I personally need to use component video, this guide will include the steps necessary to use either HDMI or Component video.
Software you will need:
- Linux Mint Live DVD iso
- Universal USB installer (Cuz we are lazy…)
- Putty or any other SSH client (Will be used later)
- Sam Nazarko’s Crystal HD for Apple TV Thumb-drive install tool
Step 1 – Give Credit Where Credit is Due
Sam Nazarko has, on his own built and maintained the tool that makes this all possible. Go to stmlabs.com and send him a donation! Seriously… Do it now =)
What Sam’s tool does is really quite amazing. You can read a lot more about it on his blog, but the short version is this… First, you download a small tool that will automatically format and partition your thumb drive (formerly a daunting task for the Linux n00b.) Then the tool will image the USB drive with a custom Linux installation already pre-configured with XBMC and all the drivers needed to run the AppleTV with a CrystalHD card. But that’s only half the story since Sam also maintains a server that allows the AppleTV to “phone home” (but only if you want it too!) at each boot and check for any updates to either the the Linux image, OS configuration, XBMC or even the CrystalHD driver. Updates have been steady so far and each one has brought improved performance and features.
Donation made? Good… Next, Go to XBMC.org and make a donation to the team there as well. These guys work very hard to make what amounts to the very best available media player and they ask nothing in return. XBMC is maintained as well as or better then most retail media players, but XBMC is totally free. The team maintains a superb support forum and the developers themselves are very active in both troubleshooting and building new improvements and features. They deserve a lot of credit and a little cash too!
So, in re-cap:
- Donate to Sam
- Donate to Team XBMC
- Move on =)
Step 2 – Install Sam’s CrystalHD for AppleTV Tool
Video How To (Getting and using Sam’s tool:)
Got to Sam’s site (http://www.stmlabs.com/projects/crystalhd-for-appletv/) and get the tool from the bottom of the page. Unzip the file and run the executable program “partitioner.exe.”
The tool will give you two options, USB Drive or Hard Drive. For this install we want to use the default USB option. The hard drive option will cause the USB drive to install the image onto the internal drive of the AppleTV… Since we are going to remove the hard drive, we will use the USB option and have the tool build us a self contained bootable thumb-drive.
In the center of the application select your USB drive from the list. If you do not see it, it must not be installed or formatted properly. Windows will need to see the drive before Sam’s tool can use it. Find your thumb-drive, check the box, make sure you are connected to the Internet and click GO.
The tool will now format the USB drive, download a 550MB image from Sam’s site and write the image to the drive. This will take some time… While you wait… Go rip apart the Apple TV as described in Part 3!
When its all done, you should see this:
Step 3 – Use Linux Mint Live CD/USB to Edit Files on the Thumb-Drive
At this point you already have a fully functional and bootable AppleTV USB Key and you can just plug it in and boot the AppleTV so long as you have not yet removed the hard drive. However the point of this guide is to remove the internal drive drive so we will need to edit a couple files in the thumb-drive since the device name will have changed.
Why do we need to edit files in Linux???
When a hard drive is installed in the AppleTV it is given the device name /dev/sda (with partitions defined as /dev/sda1, /dev/sda2, etc…) and an attached USB drive is named /dev/sdb. But, with no hard drive installed, the USB drive takes the /dev/sda name. This is a lot like in windows with the main drive being named “C:” and subsequent drives getting assigned “D:”, “E:” or “F:”, Etc… With Linux on the Apple TV, the letter after the “/sd” represents the order hat the drives are discovered by the OS based on where they are physically attached. Since Sam’s tool is designed to boot from the USB drive and not interfere with what is on the hard disk, a number of configuration files explicitly call the full path “/dev/sdb#” (the # represents the partition number) and as a result we will need to change those files and point them to “/dev/sda#” instead.
The AppleTV hardware requires that there be a number of separate partitions on its boot device and it must be partitioned in the GPT format. Unfortunately only certain tools (read: not Windows) can read that format and make the data available to us without first booting into the Apple TV.
To access the files locked inside the thumb-drive we will use the Linux Mint Live image from (yet another…) USB thumb-drive. I use the universal tool above to create the bootable thumb drive since I am lazy and this small app does all the work! Linux Mint is very similar to Ubuntu and you are free to use whatever Linux distro suites you best so long as it has GParted available. The GParted live CD (or USB) will work too, but Mint will allow you to edit the files more easily using either nano or Gedit. Also, since Mint is a more robust distro you can use the pre-loaded web browser to cut and past the commands directly from this guide (assuming Mint can find your network hardware.) Both live images will allow us to boot a computer into a Linux environment that can then mount each of the partitions on the USB drive so we can edit the necessary files. In addition, since we will have access to the root file system, we can set an IP address and modify the xorg.conf to enable component video.
Note – Using a bootable Live USB thumb Drive should not affect the hard drive of the computer you use to boot with. Live CDs/DVDs/USB drives are a great way to test drive linux on your PC with no real commitment!
Video How To (Creating a Linux Mint USB Thumb drive)
Video Pending… But uts REALLY easy, just go to Pendrivelinux.com and get the universal installer. Then use it to make a “Mint 12 DVD” based thumb drive.
3.1 Boot to Mint
Build the Mint bootable USB thumb-drive using the Universal USB Installer from pendrivelinux.com. Run the app, Select Linux Mint 12 DVD, download the Knoppix ISO from the their website (use the check box in the Installer app to automatically find the ISO) and build the drive. There is no need to create a “user space” so do not worry abort the option. When the build is complete, plug the USB drive into a computer and boot to it. Soon after, you should have a desktop running Linux Mint. If it doesn’t work, try another computer with older or more generic hardware.
In this guide I will be using the Mint Live image and will be booting from a thumb-drive as opposed to the CD. I will also be editing files in GEdit since is is easier to use then nano or VI, but you may use any text editor you prefer. Booting from a USB drive will cause my internal hard drive to be mapped as /dev/sda, the bootable Mint thumb-drive to be /dev/sdb and finally the AppleTV thumb-drive (when plugged in) to become /dev/sdc. If I were to use a live CD there would be one less device and the AppleTV thumb-drive would be /dev/sdb. This is all confusing I know, and to a windows user it’s down right mind numbing. But don’t worry, just try and boot with a USB thumb drive in a computer with only a single hard drive and then all the device names should match my examples! But if you must use a CD, remember that everywhere I use “/dev/sdc” you will likely needs to replace it with “/dev/sdb.”
3.2 – Plug in the newly created Apple TV thumb-drive to mount the partitions
Video How To (Using Linux Mint to edit the boot files:)
Plug in the AppleTV thumb-drive after the Mint desktop is visible. If everything went according to plan you should be presented with a pop up showing that the USB drive was detected and two new drives should show up on the desktop, “Linux” and “Recovery.” Ignore the popup…
At this point we could use the mouse to navigate the file system, but it may be faster to just list off the commands to run, so I am going to do it that way! Click on the Menu option in the lower left of the desktop and selct the “Terminal” option. This will open a white terminal window.
3.2.1 Modify com.apple.boot.plist in the recovery Partition
Enter the command:
sudo gedit /media/Recovery/com.apple.boot.plist
This will launch GEdit (like notepad…) in a window and open the file “com.apple.boot.plist” from the Recovery (boot) partition on the Apple TV. Leave the terminal window open even though it will display useless information from GEdit while that app is open.
GEdit will look like this:
Now from within the text editor, use the arrow keys to locate the line of text that reads as follows:
<string>root=/dev/sdb3 ro vesa video=vesafb<string>
Change the /dev/sdb3 to /dev/sda3
<string>root=/dev/sda3 ro vesa video=vesafb<string>
Why are we doing this? The HFS+ “recovery” partition is used by the AppleTV kind of like a BIOS in a traditional PC. When a USB device is plugged into the AppleTV with a properly formatted recovery partition, the apple TV will use it (instead of the hard drive) as the boot partition. By modifying the com.apple.boot.plist file we are telling the AppleTV to continue its boot process from the third partition on the first drive. Since Crystalbuntu expected there to be a hard drive at /dev/sda it was designed to boot from /dev/sdb so that the hard drive will be ignored and Crystalbuntu can boot from the thumb drive. Now that the hard drive is gone, we need modify the device name in the file to continue to point to the thumb drive, now named /dev/sda.
Finally, save the file from the title menu and close GEdit.
If you cannot save - Sometimes the file system of the thumb drive will get corrupted and this will make it so that you cannot save the file… If this happens, just re-create the drive with Sam’s tool. I’m sure that there is also a file system check that could be done to repair the corruption, but I always just use Sam’s tool to re-image the drive.
3.2.2 Modify the fstab file on the ext3 “Linux” partition
The “Linux” partition should also be monted on the desktop of Mint, and it is actually the root file system that will be used by Linux on the AppleTV while it is running. The fstab file is the “File System Table” and it tells the OS where various partitions are mounted. In much the same way that we modified the boot file, we need to update this table to replace the /dev/sdb references with /dev/sda.
To edit the file, run the following command in the terminal window used before, or open a new one:
sudo gedit /media/Linux/etc/fstab
In the text editor, locate any instance of the text /dev/sdb# (such as /dev/sdb3 or/dev/sdb2) and replace the /sdb with /sda, i.e. /dev/sdb2 will become/dev/sda2 and /dev/sdb3 will become /dev/sda3.
Here is what is will look like before you edit:
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 # /dev/sdb3 /dev/sdb3 / ext3 noatime,errors=remount-ro 0 $ # /dev/sdb2 /dev/sdb2 none swap sw 0 0
here is what it needs to look like (edits are red):
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 # /dev/sda3 /dev/sda3 / ext3 noatime,errors=remount-ro 0 $ # /dev/sda2 /dev/sda2 none swap sw 0 0
Again, save the file from the title menu and close GEdit.
That’s it! The device will now boot from the USB Drive with no more edits.
But… There are a few more things that can be useful, so if you want to set a static IP address or set-up component video, keep reading!
3.3 Modify the /etc/network/interfaces to set an IP address
Video How-To (Adding a Static IP Address)
In my network I want my AppleTV to have a static IP address, and to do that I need to set an IP in the /etc/network/interfaces file as well as setup DNS in the /etc/resolv.conf file. If you want your AppleTV to use DHCP, ignore this step. Also, DNS is critical! At each boot Crystalbuntu looks for updates, and on the first boot it is mandatory to retrieve the XBMC application and CrystalHD drivers. If you set an IP here without also setting up DNS (next step), Crystalbuntu will not boot!
Type the following command to open the file in a terminal window:
sudo gedit /media/Linux/etc/network/interfaces
The file will look like this (note the DHCP reference in the last line):
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp
And you need it to look more like this (edits in red:)
(NOTE: replace the addresses below with what you want for your network)
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.1.101 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1
Save the file and close the window.
Next, we will need to add DNS information to the /etc/resolv.conf file.
sudo gedit /media/Linux/etc/resolv.conf
The file will be empty, so add these lines (Edit the first line to match your local router or DNS, the second line is a free DNS server and is optional.)
Save the file and close the window.
3.4 – Edit the xorg.conf file to enable 720p (or 1080p) over Component video
Video How-To (Editing the xorg.conf file)
If you use HDMI, forget about this section… But if you need component video output (or composite), you need to edit the xorg.conf file. Most guides tell you to do this, but not how… Well… It’s very easy and this is what I did so feel free to cut and paste right out of this guide!
Run the command:
sudo gedit /media/Linux/etc/X11/xorg.conf
This will open the xorg.conf file in GEdit. Once open, navigate with the mouse or arrow keys to the end of the file and look for the section that starts with:
You will need to add the following four lines under the Monitor “monitor0” section.
Option "UseDisplayDevice" "TV" Option "TVOutFormat" "COMPONENT" Option "TVStandard" "HD720p" Option "TVOverScan" "0.80"
And then, under the SubSection “Display” line, add one more line:
Modes "1920x1080" "1280x720" "1024x768" "720x480" "800x600" "640x480"
The result should look like this (edits in bold:)
Option "UseDisplayDevice" "TV"
Option "TVOutFormat" "COMPONENT"
Option "TVStandard" "HD720p"
Option "TVOverScan" "0.80"
Option "NoLogo" "True"
Modes "1920x1080" "1280x720" "1024x768" "720x480" "800x600" "640x480"
When done it should look like this at the bottom of the file:
Hit save in Leafpad and close the window.
NOTE – If you need Composite video, you may try the following… But DO NOT DO THIS unless you NEED Composite.
For composite output, Connect a cable from the green (luma) component output on the AppleTV to the yellow composite input on the TV. The xorg.conf need the following settings for “Section Screen”Section “Screen” instead of those posted above.
Identifier "Screen0" Device "Device0"
Monitor "Monitor0" DefaultDepth 24 Option "DPI" "100x100" Option "UseEvents" "1" Option "AddARGBVisuals" "1" Option "AddARGBGLXVisuals" "1" Option "UseDisplayDevice" "TV" Option "UseEDID" "FALSE" Option "TVOutFormat" "COMPOSITE" Option "TVStandard" "NTSC-M" Option "TVOverScan" "0.80 Option "NoLogo" "True" Option "Coolbits" "1" SubSection "Display" Depth 24 Modes "720x480" "640x480" EndSubSection EndSection
Section "Extensions" Option "Composite" "Disable" EndSection
3.5 – Closing out of Mint
That’s it! We are all done with Mint so shutdown the computer now and plug the AppleTV USB key into the AppleTV!
Now - If you have not already done so, rip apart the hardware in Part 3 – Modifying the Apple TV Hardware