• Home
  • Articles & Guides
    • Configure a Synology NAS as MySQL server for XBMC
  • What’s New
  • Crystalbuntu How-to
    • Intro – From HTPC to Apple TV
    • Part 1 – Introduction
    • Part 2 – Preparing The Thumb-drive
    • Part 3 – AppleTV Hardware Modification
    • Part 4 – The First Boot
  • Coffee!
  • About Us
  • Contact Us

Crystalbuntu Installation Guide – Part 2 – Preparing The Thumb-drive

Posted by Mark - December 2, 2011 - Crystalbuntu, How To
23
Crystalbuntu Installation Guide – Part 2 – Preparing The Thumb-drive

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
    • http://www.linuxmint.com/download.php
  • Universal USB installer (Cuz we are lazy…)
    • http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/
  • Putty or any other SSH client (Will be used later)
    • http://www.chiark.greenend.org.uk/~sgtatham/putty/
  • Sam Nazarko’s Crystal HD for Apple TV Thumb-drive install tool
    • http://www.stmlabs.com/projects/crystalhd-for-appletv/

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:

  1. Donate to Sam
  2. Donate to Team XBMC
  3. 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.)

nameserver 192.168.1.1
nameserver 8.8.8.8

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:

Section "Screen"

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:)
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
Option "UseDisplayDevice" "TV"
Option "TVOutFormat" "COMPONENT"
Option "TVStandard" "HD720p"
Option "TVOverScan" "0.80"

DefaultDepth 24
Option "NoLogo" "True"
SubSection "Display"
    Modes "1920x1080" "1280x720" "1024x768" "720x480" "800x600" "640x480"
Depth 24
EndSubSection
EndSection

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

Remove:

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

  • Pingback: Crystalbuntu Installation Guide – Part 3 – AppleTV Hardware Modification | QuixVenture.com

  • scott Q

    maybe im missing something here but i cannot edit the com.apple.Boot.plist file.  It is read only and I cannot seem to bypass it.

    • QuixVenture

      Hi Scott –

      This happens every so often and generally means that the file system is corrupted. I have no idea why it happens, but it’s happened a few times to me. Just re-run the app to create the thumb drive and try again.

    • Aaron Stransky

       if using ubuntu, open nautilis (sudo nautilus) and then browse to the file.

      • Mark

        Hi Aaron,

        Thanks for the helpful tip! But… since there is no good reason for the file to be read only when using “sudo gedit” I still think its best to start over with a fresh install. This only ever happens to me when the file system has been corrupted.

  • Adam Hodge

    Ok, im pulling my hair out over this.  I’m stuck on step 3.2.1 I cannot seem to get the com.apple.Boot.plist file to open with the read-only tag.  I have even attempted to copy the file to the Mint desktop and edit the file there and copy back to the /media/Recovery partition which fails as the destination is read-only.  What am i missing here?  PLEASE HELP!

    • QuixVenture

      Well.. This actually happens a lot and I will make a note of it in the guide. This means that the file system has been damaged and you need to re-create the thumb drive.

      Just start over again, and all should be OK. You can probably also do a file system check on the drive itself, but I cannot recall the command off hand…

      And one more note, ALWAYS unmount the drive from windows and Linux before removing. That’s generally what causes this.

      • Adam Hodge

         Quix,

        I assume you mean the file system of the Linux Mint 12?  I have tried
        this now with a 32GB USB drive, a CD, a DVD in both 32 and 64 bit
        versions.  I will remake the thumb drive and be sure to unmount from my
        Windows machine before I remove it and see what happens.  Thanks for
        your rapid response!

        • QuixVenture

          Hi Adam -

          Sorry if I was not clear, actually I mean the file system of the Crystalbuntu thumb drive… Just use Sam’s tool to re-build it.

          • Adam Hodge

             Does that rebuild tool fix the installation or wipe it and start from scratch?  I don’t want to lose my Crystalbuntu installation and XBMC setup.  Thanks again for your help!

          • QuixVenture

            Hi Adam – I didn’t realize that you were using an existing thumb drive. You will need to do a file system check using Mint. I am not 100% sure that this will fix you up, but try these commands:

            sudo apt-get install hfsprogs
            sudo fsck -V /dev/sdb1

            This assumes that the thumb drive is seen by Mint as /dev/sdb1, and depending on your computer that may not be the case (it may be /dev/sdc etc…)

            To make sure, in Mint, use the Applications Menu to get to:
            Applications > Accessories > Disk Utility

            Then locate your thumb drive and click it. Then check the “device:” info on the second column near the top. If it’s /dev/sdb all is good and just do what I said above.. If not, just replace the /dev/sdX1 section with whatever you see in the tool (and add a “1″ to the end.)

            Let me know how it goes!

            -Mark

          • dragontails

            Great guide Mark. Thank you. I followed your youtube video as well and peeled off and cleaned the rubber bottom as well. Nice solid result. 

            I too am having this problem with read only partition. To me, it kinda makes sense the ‘restore’ partition would be read only. I haven’t tried recreating the thumb drive yet though as I am suspicious this is not the intention of Sam’s tool. I figure I can just google how to turn partition into read/write then undo that when complete. But, I come here in search of answers. Maybe the output of Sam’s tool has changed? Maybe you turned your partitions into read/write while experimenting? Maybe the output is indeed corrupt? Thank you again.

  • http://twitter.com/StevenP88958975 StevenP

    Hi Mark, this is a great post and I really think it will help me.  I am in a strange situation. I have a 27″ CRT that can only accommodate 480i but it has a component input as well as composite.  The Apple TV 1 OS works over the component cable in 480i, so how can I get Crystalbuntu to do the same?  Would I use the same settings as you did for 720p but change the resolutions supported to ones my tv can use, or should I just try the composite route?  I think I get a much cleaner picture from component and would prefer that.

    • http://www.quixventure.com/ Mark (QuixVenture)

      Hi StevenP – I would absolutely use Component if your TV supports it, and yes, just change the options to the include only the resolutions you can support.

      So change the TV Standard to “HD480i” and set the mode line to only include the resolutions that you can actually support, i.e. “648×480″ etc…

      I do not have any TVs to try this out on as all of mine are wide screen, but I did try the “HD480i” option and it definitely changed my default resolution over both Component and HDMI.

    • http://twitter.com/mkvXstream mkvXstream

      Hi Steven,

      Also have an older Sony XBR and even though it does 1080i nothing over 480i will work. Either get a black screen or pink wavy lines. Good news is the videos player a little higher quality than 480i but seems to be a limitation we run into with older tech TVS.

  • Surreal2010

    Hi Mark,

    Thanks for this post! Got it all set up up now except for the Analog Audio (RCA) that doesn’t give me any output. This happens both with the HDMI and the component setup. Any clue on how to solve this? Have tried all possible settings in XBMC already but maybe I need to modify a .conf file instead. Would be great if you could help me out on this one.

    Thanks

    • http://www.quixventure.com/ Mark (QuixVenture)

      Hi Surreal –

      Over at STMLabs Sam has the following post about analog audio:

      Users not using HDMI should run the following command over SSH:

      sudo rm /etc/asound.conf

      Try that (I think I had to do it too… But its been a while!)

  • racertimx

    I can’t edit the fstab partition when I type in the command line into terminal a blank screen appears, did I do something wrong? Any help would be appreciated and thank you in advance

  • yeahman

    Question, how can you reduce the writes to the flash drive to reduce wearing it out?

    • http://www.quixventure.com/ Mark (QuixVenture)

      Hmmm, interesting question, but not sure how to answer. I use MySQL for the database on a NAS, so I doubt that I have many writes at all on my USB. That’s probably the best way to go as it will essentially make every file on the stick static unless there are updates from STM labs or XBMC add-ons. Even in Frodo the thumbs will be write once read many for the most part.

      • yeahman

        I also am using a NAS to retrieve my data, but mine is a SnapServer
        Linux based. Can you give me more details on how you setup/install MySQL. I know nothing about it. Another question I have. There is a plugin called
        cache-in or something like that which I have turned off, because I believe it is cacheing to the flash drive. Is there anyway to redirect this plugin to my NAS’s HDD for cacheing? I guess it would be nice if you could show us how to reduce writes and caching to the flash drive to extend the life of the flash drive. Thanks again.

  • Arvin

    I came to this site a little too late. I already booted my ATV1 after plugging the usb drive with crystalbuntu and after doing all the compilations etc, XBMC came up fine. However I want to add a static IP address to it. What is the easiest way to do that? Should I shutdown my ATV1, take out the usb drive and stick into my laptop which is running Linux Mint and use the above instructions for static IP? Or do I need to create a usb drive with crystalubuntu from scratch and follow along the instructions here?

  • Alex

    I am trying to load Crystalbuntu on my ATV1 with a hard drive still in it. I have tried making the USB drive for both USB booting and for the internal hard drive. Each time I do it, the PC says it is succesful but when I put it in the ATV it just boots up as normal, seemingly ignoring the USB drive! Any ideas why this might be and the best solution?
    Thanks

Search Our Site

Google Ad

(c) 2012 QuixVenture.com - Web Design by Cales.ca
  • Home
  • Articles & Guides
  • What’s New
  • Crystalbuntu How-to
  • Coffee!
  • About Us
  • Contact Us