Archive:HOW-TO:Install Gentoo and XBMC on Apple TV 1: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Xett
>Xett
Line 124: Line 124:


===Partition your internal ATV Hard Drive===
===Partition your internal ATV Hard Drive===
Now that everything is backed up, you can create the new partition structure for your linux installation. This may seem confusing, but it is sort of straight forward when you understand what is going on under the hood.
On your local ATV disk you are essentially creating a partition structure to support two separate OS installations; One for a local copy of the atv-bootloader to live in, the other for your gentoo installation. When your ATV boots, its EFI needs to talk to the atv-bootloader kernel/os. After this pow-wow is done, atv-bootloader hands the machine off to your gentoo installation. Makes sense, right? Good.
Again, make sure /dev/sda is your local ATV hard drive.
Zero out /dev/sda so its guid changes...
dd if=/dev/zero of=/dev/sda bs=4096 count=1M
create initial gpt structures
parted -s /dev/sda mklabel gpt
We need to find out how large our disk is, run this:
parted -s /dev/sda print
This should spit out something like below:
Model: ATA WDC WD1600BEVE-4 (scsi)
Disk /dev/sda: 160GB
Here it tells me my local disk (/dev/sda) is 160GB, hurrah for me. This makes 160GB the end of our disk, remember this.
You're now going to create the three partitions required for the atv-bootloader.
parted -s /dev/sda mkpart primary fat32 40s 25M
parted -s /dev/sda set 1 boot on
parted -s /dev/sda mkpart primary HFS 25M 50M
parted -s /dev/sda set 2 atvrecv on
parted -s /dev/sda mkpart primary HFS 50M 75M
At this point you've created the partitions nessesary for installing the local copy of the atv-bootloader.
The next could partitions you make will be for gentoo and can be whatever sizes you like, though I recomend at least 1gig of swap.
I've made my root partition about 16GB and swap 1000MB, create those now:
parted -s /dev/sda mkpart primary ext3 75M 16GB
parted -s /dev/sda mkpart primary linux-swap 16GB 17GB
You'll notice that yes, this leaves a ton of my disk unused. I stream everything, so this doesn't bother me. You can always format the remain space and mount it up as a storage partition:
#Optional:
parted -s /dev/sda mkpart primary ext3 17GB 160GB
Sync up your partition tables
partprobe /dev/sda
Get everything formatted:
mkfs.msdos -F 32 -n EFI /dev/sda1
mkfs.hfsplus -v Recovery /dev/sda2
mkfs.hfsplus -v OSBoot /dev/sda3
mkfs.ext3  -b 4096 -L Linux /dev/sda4
mkswap /dev/sda5
sync
Time to see if we got everything correct:
parted -s /dev/sda print
This should spit out something very similar to this:
Model: ATA WDC WD1600BEVE-4 (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start  End    Size    File system    Name    Flags
1      20.5kB  25.0MB  25.0MB  fat32          primary  boot
2      25.0MB  50.0MB  25.0MB  hfs+            primary  atvrecv
3      50.0MB  75.0MB  25.0MB  hfs+            primary
4      75.0MB  16.0GB  15.9GB  ext3            primary
5      16.0GB  17.0GB  1000MB  linux-swap(v1)  primary
Ensure the 'Flags' section is the same as above and that your first three partitions (at least) match mine.
That concludes all the partition setup that is needed. The next step is to install a LOCAL copy of the atv-bootloader magic on to the ATV's hard disk (remember, up until now we've been opperating in the live environment)


===Install the atv-bootloader onto the internal disk===
===Install the atv-bootloader onto the internal disk===

Revision as of 14:56, 23 September 2010

Install Gentoo and XBMC on the AppleTV

These instructions will help you on your way to getting Gentoo intalled on your Apple TV. This guide is for a total ATV overhaul -- which is to say replacing the OSX-lite ATV OS with Gentoo. As such it has the possibility of totally toasting your pretty silver box. These steps do NOT require you to crack open your ATV and slave up its disk to an existing pc. This is of course an option, but IMHO, totally unnecessary.

Most of this guide was stolen right off http://code.google.com/p/atv-bootloader. I give full praise and credit to these guys. atv-bootloader is a truely awesome little bit of work. This guide assumes you are comfortable with a gentoo command-line installation and kernel configuration, telnet/ssh connections, network basics, partition/disk schemes, etc. If terms like "dd", "mbr", "efi" and "parted" don't mean anything to you, you should probably close this document and go grab a Ubuntu ISO. Not that I don't love Ubuntu :-)

You will also need an existing linux machine (or, yes, OSX would work too). This linux machine will be used to build the initial ATV-Bootloader USB stick, as well as telnet into your atv during the process. I used a gentoo box, and thus these instructions will be geared in that direction. Keep in mind some part may deviate, depending on your distro.

Your ATV and linux machine will need to be on the same lan with dhcp setup (should be a no brainer)

Herrrrrreeee we go...




Create an AppleTV Patchstick

(not to be confused with the atv-bootloader stick)

Head on over to http://code.google.com/p/atvusb-creator/ and download whatever flavor of the patchstick tool suites your OS. Extract it to a directory and run it. It will download a new version of the ATV firmware for you, put it in a juicer and pop out a nice little .img file for you to put on a USB drive. It will also produce you your very own boot.efi file. Hold on to this file, it will be important later.

Create an ATV-Bootloader USB Stick

All the linux commands I've listed here should be run as root, unless otherwise noted

On your linux machine, get your distros copy of GNU Parted. On gentoo, the package is called parted, so;

emerge -v parted


You will also need HFS+ tools. Portage has got a package called sys-fs/hfsplusutils, but I found it to suck. Your best bet is to grab the tar off the atv-bootloader site, do the following as your root;

cd ~	
wget http://atv-bootloader.googlecode.com/files/hfs_support-1.0.tar.gz
tar -xzf hfs_support-1.0.tar.gz
cd hfs_support/
./build_diskdev_cmds.sh


You'll now have your own copies of various hfsp utilities you will need moving forward. Get an empty usb drive of at least 512mb and plug it into your linux machine, lets assume it gets assigned to device node /dev/sdb The following commands zero out the device then create and format the usb partitions:

dd if=/dev/zero of=/dev/sdb bs=4096 count=1M
partprobe /dev/sdb
parted -s /dev/sdb mklabel gpt
parted -s /dev/sdb mkpart primary HFS 40s 69671s
parted -s /dev/sdb set 1 atvrecv on
partprobe /dev/sdb
mkfs.hfsplus -v Recovery /dev/sdb1
cd ~
mkdir atvbootloader
mount /dev/sdb1 atvbootloader/


Now download and copy over the atv-bootloader files;

wget http://atv-bootloader.googlecode.com/files/recovery-0.6.tar.gz
tar -xzf recovery-0.6.tar.gz
cp -arp recovery/* atvbootloader/


That disk is now set up, so copy over that handy boot.efi that the Patchstick util found for you. If you created the patchstick on windows you'll need to copy the boot.efi file over to your linux machine, then copy it to the bootloader stick. You can use PSCP, ftp, or another flash disk, whatever you want. Just make sure it ends up on your atv-bootloader disk:

cp -ap boot.efi atvbootloader/


Now edit the boot.plist file from the recovery software to drop you to a command prompt. I'm a vi-guy, but you can use nano or whatever you want:

vi atvbootloader/penboot/com.apple.Boot.plist


Change one of the last lines in that file to read:

<string>atv-boot=none video=vsesafb</string>

Save and quit vi (:wq [enter]), unmount your usb atv-bootloader.

You've now got an awesome little usb drive that will boot your appletv to a live linux installation. W00t.


Backup your internal ATV Hard Drive

Boot your AppleTV to your new atv-bootloader usb drive. You may need to hold down the remote's [-] and [Menu] buttons at boot to force it to scan for usb devices.

atv-bootloader should load up after a minute or so and drop you at a login prompt.

You can login with root/root and do everything locally with a USB keyboard if you wish, but using telnet is much easier.

Gentoo does not 'ship' with telnet tools, so emerge them:

emerge -v netkit-telnetd

Then connect to your atv (this does not have to be done as root on your client machine):

telnet [your ATV's IP]

Again, root/root for passwords.

Figure out which of the device nodes represents your LOCAL disk on the ATV. I've had it map as both sda and sdb on occations, so I can't definitivly tell you which is will be. I assume that your local disk has detected as /dev/sda for the ballance of this guide.


At this point, you have two options: Lazy and Correct.

The Lazy (and slow) way to take a backup of your ATV is to plug in an external hard disk (lets assume its partition is /dev/sdc1) and run

mkdir /mnt/backup/
mount /dev/sdc1 /mnt/backup/
dd if=/dev/sda | gzip > /mnt/backup/atv-backup.dd.img

That will take a complete bit-for-bit backup of your disk. It will pipe it through gzip, so you will get good compression if most of your disk is empty, but if you have your local disk full of media, make sure your target external drive is at LEAST the size of your ATV's internal drive.


The far more 'correct' way to do an ATV backup is detailed on the atv-bootloader site. Its best to just follow the official guide on this page, as I have zero customization to add:

http://code.google.com/p/atv-bootloader/wiki/ATVBackup#Backup

When you are done with the Backup section of that page, come back here and continue on...

Partition your internal ATV Hard Drive

Now that everything is backed up, you can create the new partition structure for your linux installation. This may seem confusing, but it is sort of straight forward when you understand what is going on under the hood. On your local ATV disk you are essentially creating a partition structure to support two separate OS installations; One for a local copy of the atv-bootloader to live in, the other for your gentoo installation. When your ATV boots, its EFI needs to talk to the atv-bootloader kernel/os. After this pow-wow is done, atv-bootloader hands the machine off to your gentoo installation. Makes sense, right? Good.

Again, make sure /dev/sda is your local ATV hard drive.

Zero out /dev/sda so its guid changes...

dd if=/dev/zero of=/dev/sda bs=4096 count=1M

create initial gpt structures

parted -s /dev/sda mklabel gpt

We need to find out how large our disk is, run this:

parted -s /dev/sda print

This should spit out something like below:

Model: ATA WDC WD1600BEVE-4 (scsi)
Disk /dev/sda: 160GB

Here it tells me my local disk (/dev/sda) is 160GB, hurrah for me. This makes 160GB the end of our disk, remember this.

You're now going to create the three partitions required for the atv-bootloader.


parted -s /dev/sda mkpart primary fat32 40s 25M
parted -s /dev/sda set 1 boot on
parted -s /dev/sda mkpart primary HFS 25M 50M
parted -s /dev/sda set 2 atvrecv on
parted -s /dev/sda mkpart primary HFS 50M 75M

At this point you've created the partitions nessesary for installing the local copy of the atv-bootloader. The next could partitions you make will be for gentoo and can be whatever sizes you like, though I recomend at least 1gig of swap.

I've made my root partition about 16GB and swap 1000MB, create those now:

parted -s /dev/sda mkpart primary ext3 75M 16GB
parted -s /dev/sda mkpart primary linux-swap 16GB 17GB

You'll notice that yes, this leaves a ton of my disk unused. I stream everything, so this doesn't bother me. You can always format the remain space and mount it up as a storage partition:

#Optional:
parted -s /dev/sda mkpart primary ext3 17GB 160GB

Sync up your partition tables

partprobe /dev/sda

Get everything formatted:

mkfs.msdos -F 32 -n EFI /dev/sda1
mkfs.hfsplus -v Recovery /dev/sda2
mkfs.hfsplus -v OSBoot /dev/sda3
mkfs.ext3  -b 4096 -L Linux /dev/sda4
mkswap /dev/sda5
sync 

Time to see if we got everything correct:

parted -s /dev/sda print

This should spit out something very similar to this:

Model: ATA WDC WD1600BEVE-4 (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End    Size    File system     Name     Flags
1      20.5kB  25.0MB  25.0MB  fat32           primary  boot
2      25.0MB  50.0MB  25.0MB  hfs+            primary  atvrecv
3      50.0MB  75.0MB  25.0MB  hfs+            primary
4      75.0MB  16.0GB  15.9GB  ext3            primary
5      16.0GB  17.0GB  1000MB  linux-swap(v1)  primary

Ensure the 'Flags' section is the same as above and that your first three partitions (at least) match mine.

That concludes all the partition setup that is needed. The next step is to install a LOCAL copy of the atv-bootloader magic on to the ATV's hard disk (remember, up until now we've been opperating in the live environment)

Install the atv-bootloader onto the internal disk

Installing Gentoo

Basic Gentoo Environment

Chroot in and Edit Environment

Make.conf options

System config and Update

Kernel Config

Boot Setup and Options

Install Packages

Basic Stuff

Xorg

Installing XBMC