My favorites | Sign in
Project Logo
             
Search
for
Updated May 26, 2008 by sdavilla
LinuxUSBPenBoot  

ATV-Bootloader on USB flash disk

In this guide, we will build an atv-bootloader based USB flash disk that can be used for standalone boot. We will also enable telnet so we don't need a USB keyboard attached and can do everything remotely using a telnet session using a wired network connection. Unfortunately, wireless is not supported at this time.

Since atv-bootloader contains all the disk tools required for creating GPT formatted partitions, one can use it to boot, partition and install Linux with a USB cdrom using only the AppleTV. Of course you do need a working Linux system to first create this USB flash disk.

We need our standard items for creating an AppleTV "Recovery" partition. These are boot.efi, the patched parted and hfs tools. See extract boot.efi for boot.efi, install parted for parted and install hfs tools for hfs support. Test that you have to correct parted.

parted --version

parted (GNU parted) 1.8.8
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by <http://parted.alioth.debian.org/cgi-bin/trac.cgi/browser/AUTHORS>.

Assuming you have these items extracted/built/installed, let's start.

Create the recovery partition on a USB pen disk, this does not require very much space so 64MB or greater pen drive is fine. I recommend a USB flash disk of 512MB or greater, that way you can also use the same disk to backup the AppleTV. Make sure the USB flash drive is unmounted, most Linux distros will auto-mount USB flash drives. If you have problems partitioning, you might have a USB flash drive that needs fixing.

This guide assumes the device at "/dev/sdb" is the pen drive so remember to adjust this to match your device setup or very bad things will happen

# zero the initial sectors
sudo dd if=/dev/zero of=/dev/sdb bs=4096 count=1M

# sync the system disk partition tables
sudo partprobe /dev/sdb

# create the GPT format
sudo parted -s /dev/sdb mklabel gpt

# create just a recovery partition
sudo parted -s /dev/sdb mkpart primary HFS 40s 69671s
sudo parted -s /dev/sdb set 1 atvrecv on

# sync the system disk partition tables
sudo partprobe /dev/sdb

Verify that it looks fine and the atvrecv flag is set

sudo parted -s /dev/sdb unit s print

Model: SanDisk Cruzer Micro (scsi)
Disk /dev/sdb: 501759s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End      Size     File system  Name     Flags  
 1      40s     69671s   69632s                primary  atvrecv

Format this partition hfsplus

# format it
sudo mkfs.hfsplus -v Recovery /dev/sdb1

# mount it
mkdir penboot
sudo mount /dev/sdb1 penboot

# download atv-bootloader (recovery.tar.gz) and install it
wget http://atv-bootloader.googlecode.com/files/recovery-0.6.tar.gz
sudo tar -xzf recovery-0.6.tar.gz
sudo cp -arp recovery/* penboot/

Remember to copy boot.efi to penboot/

sudo cp -ap boot.efi penboot/

Override the normal auto boot sequence as we need to get into a command-line enviroment and get telnetd started. Edit "penboot/com.apple.Boot.plist" on the recovery partition and change the atv-boot parameter from "auto"

<string>atv-boot=auto video=vesafb</string>

to "none"

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

When "none" is selected, atv-bootloader now drops to a command-line login, enables wired networking using DHCP, prints the network config so you know the IP address and starts the telnet demon.

Unmount the disk and we are done building atv-bootloader on a USB pen disk.

sudo umount penboot

Usage

Boot the AppleTV using the USB pen disk. Remember you have to force a "Recovery Boot" by holding "menu" and "-" buttons down on the Apple IR remote either during power-up or when the AppleTV OS is running.

You should see the kernel boot messages, the ifconfig dump and then a login prompt. Either login (user=root, password=root) using a USB keyboard or telnet in using the listed IP addresses. vi and nano are present as well as the parted and hfs tools for creating AppleTV GPT format partitions. You can also use this disk to backup the AppleTV and manually boot a LiveCD on a USB cdrom.

Enjoy.


Comment by sean.rhodes, Feb 25, 2009

how do I fix invalid tokens? sean@Ubuntu:~$ sudo parted -s /dev/sdc set 1 atvrecv on parted: invalid token: atvrecv

Comment by sdavilla, Feb 25, 2009

use the correct version of parted. see http://code.google.com/p/atv-bootloader/wiki/InstallParted

Comment by sean.rhodes, Feb 25, 2009

I installed the correct version but got the error at the end so I modified the script and it seemed to install OK. I tried reinstalling and got the following error ../../include/parted/natmath.h:93: error: inline function 'ped_div_round_to_nearest' declared but never defined ../../include/parted/natmath.h:90: error: inline function 'ped_div_round_up' declared but never defined make2?: rdb.lo? Error 1 make2?: Leaving directory `/home/sean/parted/parted-1.8.8/libparted/labels' make1?: install-recursive? Error 1 make1?: Leaving directory `/home/sean/parted/parted-1.8.8/libparted' make: install-recursive? Error 1

Comment by sdavilla, Feb 25, 2009

googling for "parted ped_div_round_to_nearest" show lot's of hits, including;

http://code.google.com/p/atv-bootloader/issues/detail?id=18

Comment by themartorana, Jun 14, 2009

If I telnet into my ATV and /dev/sda is my USB stick, and there is no /dev/sdb, is it fair to assume my HD is hosed?

Comment by motassa1979, Sep 02, 2009

Hi everyone,

I think I did everything good, but looks I'm wrong because I have this mistake "parted: invalid token: atvrecv" Could anyone help me? thanks.

vicen@vicen-linux:~$ parted --version parted (GNU parted) 1.8.9 Copyright (C) 2007 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Written by <http://parted.alioth.debian.org/cgi-bin/trac.cgi/browser/AUTHORS>. vicen@vicen-linux:~$ sudo dd if=/dev/zero of=/dev/sdb bs=4096 count=1M dd: en escriure «/dev/sdb»: No space left on device 31099+0 registres llegits 31098+0 registres escrits 127377408 octets (127 MB) copiats, 4,13412 s, 30,8 MB/s vicen@vicen-linux:~$ sudo partprobe /dev/sdb vicen@vicen-linux:~$ sudo parted -s /dev/sdb mklabel gpt vicen@vicen-linux:~$ sudo parted -s /dev/sdb mkpart primary HFS 40s 69671s vicen@vicen-linux:~$ sudo parted -s /dev/sdb set 1 atvrecv on parted: invalid token: atvrecv

Comment by sdavilla, Sep 02, 2009

motassa1979, -> wrong version of parted, you need to use the patched version in the download section.

Comment by motassa1979, Sep 03, 2009

thanks sdavilla,

I've tried to follow "http://code.google.com/p/atv-bootloader/wiki/InstallParted" with the correct version of parted, downloaded from download section. I copy this file into /home/vicen and I've done these orders:
sudo /usr/bin/apt-get remove parted wget http://atv-bootloader.googlecode.com/files/parted-1.8.8-atv.tar.gz tar -xzf parted-1.8.8-atv.tar.gz cd parted sudo ./install_parted.sh sudo ln -s /usr/local/sbin/parted /sbin/parted parted --version
When I've done this a message said that I hadn't installed programme parted and I needed to write "sudo apt-get install parted" to install it. I've done it and I try "parted --version" again. My surprise is that the version is 1.8.9. again!!!
What's wrong?? thanks again.

Comment by motassa1979, Sep 09, 2009

davilla, could you help me? thanks.

Comment by sdavilla, Sep 09, 2009

does it understand atvrecv ?

Comment by motassa1979, Sep 10, 2009

sorry for my English, I don't understand that you want to tell me.

what do you want to say with "does it understand atvrecv"? sorry again.


Sign in to add a comment
Hosted by Google Code