Sunday, September 16, 2012
Ubuntu Precise (12.04) on Apple TV (1st generation)
I have an Apple TV(1st generation) that I use as a HTPC running XBMC. I planned to swap out the original hard drive with a compact flash card (poor man's SSD). One of the biggest issue with swapping the original hard drive out and replacing it with a compact flash card is to find a compact flash card that will boot. It is supposed that only compact flash card that identifies itself as "fixed disk" can boot as a replacement drive inside the Apple TV. Off late most vendors dont sell compact flash card that identifies itself as a "fixed disk" when using a compact flash to IDE adapter nor do they provide any utility to do the same as they have done in the past. Finding a compact flash card that will boot as a replacement drive has been the toughest part. After experimenting with a few myself and talking with other people who have tried I was close to giving up on using a compact flash card as the bootable drive. I finally found a card that did boot.
The devices I am using are:
Compact flash to IDE adapter: Syba SY-IDE2CF-NB25
Compact flash card: Maxell 8GB compact flash card maxdata 400x
In this post I will install a minimal base system that boots and starts a ssh-server. I will use IDE to USB adapter and linux system to do the installation.
In the rest of the post the compact flash device comes up as sdb, please use the appropriate device when you are trying it out.
First we will zero out the card.
Create a GPT partition table
Create the recovery partition
Create the swap partition
Create the root partition
Format the recovery partition
Format the swap partition.
Format the root partition.
Mount the root parition
Install a minimal base system
Chroot into the base system
Fix the locale warning like like "Locale not supported by C library." or "perl: warning: Setting locale failed."
Setup the fstab, my fstab looks like this
Setup apt sources.list, my sources.list looks like this
Create a user for login
Install ssh server
To boot linux on the apple tv one needs to use the atv-bootloader [1]. One can use the atv-bootloader to kexec into the stock distribution kernel. Since I dont upgrade my kernel often I would rather avoid the kexec step. I built my own kernel with using a config that works with the atv-bootloader. After I install that kernel I create the mach_kernel that I copied into the recovery partition. I am not covering the details in this post.
Now just go ahead and replace the stock IDE hard drive with this compact flash and now you have a poor mans SSD booting in your apple tv.
[1] Apple TV bootloader
The devices I am using are:
Compact flash to IDE adapter: Syba SY-IDE2CF-NB25
Compact flash card: Maxell 8GB compact flash card maxdata 400x
In this post I will install a minimal base system that boots and starts a ssh-server. I will use IDE to USB adapter and linux system to do the installation.
In the rest of the post the compact flash device comes up as sdb, please use the appropriate device when you are trying it out.
First we will zero out the card.
# dd if=/dev/zero of=/dev/sdb bs=4096 count=2M
Create a GPT partition table
# partprobe /dev/sdb # parted -s /dev/sdb mklabel gpt
Create the recovery partition
# parted -s /dev/sdb mkpart primary hfs 40s 69671s # parted -s /dev/sdb set 1 atvrecv on
Create the swap partition
# parted -s /dev/sdb mkpart primary linux-swap 69672s 1118247s
Create the root partition
# parted -s /dev/sdb mkpart primary 1118248s 14909294s
Format the recovery partition
# partprobe /dev/sdb # mkfs.hfsplus -v Recovery /dev/sdb1
Format the swap partition.
# mkswap /dev/sdb2
Format the root partition.
# mkfs.ext4 /dev/sdb3
Mount the root parition
# mount /dev/sdb3 tmp/
Install a minimal base system
debootstrap precise tmp/ http://us.archive.ubuntu.com/ubuntu/
Chroot into the base system
# mount -o bind /proc tmp/proc # mount -o rbind /dev tmp/dev # chroot tmp/ /bin/bash
Fix the locale warning like like "Locale not supported by C library." or "perl: warning: Setting locale failed."
# echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/local # dpkg-reconfigure locales
Setup the fstab, my fstab looks like this
# /etc/fstab: static file system information. # #proc /proc proc defaults 0 0 # /dev/sda3 UUID=a0f8594c-fe28-4f6a-9312-ef684b4f5785 / ext4 noatime,errors=remount-ro 0 1 # /dev/sda2 UUID=a3592f78-72fc-4cca-884d-b8bb4c26280f none swap sw 0 0
Setup apt sources.list, my sources.list looks like this
deb http://us.archive.ubuntu.com/ubuntu precise main restricted universe multiverse deb http://us.archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
Create a user for login
# adduser foo --gecos "Foo Bar"
Install ssh server
apt-get install openssh-server
To boot linux on the apple tv one needs to use the atv-bootloader [1]. One can use the atv-bootloader to kexec into the stock distribution kernel. Since I dont upgrade my kernel often I would rather avoid the kexec step. I built my own kernel with using a config that works with the atv-bootloader. After I install that kernel I create the mach_kernel that I copied into the recovery partition. I am not covering the details in this post.
Now just go ahead and replace the stock IDE hard drive with this compact flash and now you have a poor mans SSD booting in your apple tv.
[1] Apple TV bootloader
Labels: apple tv, precise, ubuntu
Thursday, February 02, 2012
Setting up ARM chroot on Ubuntu Oneiric (11.10) for cross build
I recently ordered a Pandaboard ES so that I could learn a few things on ARM development. A caveat on ARM development, if you are going to compile anything on the device it takes significant time. When I am new to a platform, to gain experience, I build a bootable Linux kernel and install it. This lets me get a hang of recovering to a known working kernel if something screws up during a kernel upgrade. I started out building the kernel directly on the device but was bitten by a known bug which results in segfaults/sigbuses when running the Pandaboard using the entire 1GB of RAM it has. The workaround is to change the boot parameters so that only 768MB of 1GB of RAM is used. Considering the fact that it takes significant time to build things on the device, I thought why not use my old Pentium M laptop as cross compile build box. The first thing for that is to install a working ARM cross chroot environment. I contacted my good friend Google as ever. I found a lot of useful resources as usual. I thought I would document the approach that I used which worked for me.
I used EmDebian CrossDebootstrap wiki entry [1] as the starting point. I installed Ubuntu's Oneiric ARM port in the chroot and the steps are as follows:
With the chroot base system now setup one can use schroot/dchroot to chroot into the base system and install any other packages like a regular chroot. If you want to debootstrap to install a chroot to build packages one needs to just pass the --variant=buildd option to debootstrap in step 3.
[1] http://wiki.debian.org/EmDebian/CrossDebootstrap
I used EmDebian CrossDebootstrap wiki entry [1] as the starting point. I installed Ubuntu's Oneiric ARM port in the chroot and the steps are as follows:
- First and foremost is to install some of the required packages
# apt-get install binfmt-support debootstrap qemu qemu-user-static
- Create an empty directory where the chroot will be installed
# mkdir -p /chroot/oneiric_armel
- Now we bootstrap the chroot
# debootstrap --arch=armel --foreign oneiric /chroot/oneiric_armel http://ports.ubuntu.com/
This will take time depending on your network connection and drive speed, get yourself a sandwich or catch up on some email. - Since we passed the --foreign option to debootstrap the .deb files have been downloaded and unpacked, we are yet to configure the system and finalize the chroot installation. Before we can do anything we need to copy over the qemu binary into the chroot so that we can run ARM executables on the host system using emulation.
# cp /usr/bin/qemu-arm-static /chroot/oneiric_armel/usr/bin/
Now we are ready to configure and finalize the base system. - To configure the base system, first we need to chroot into and then execute the second stage of debootstrap.
# chroot /chroot/oneiric_armel/
/debootstrap/debootstrap --second-stage
exit - Now we have configured and working base system, we need to create a valid apt source list. The contents of /chroot/oneiric_armel/etc/apt/sources.list should resemble something like this.
deb http://ports.ubuntu.com/ oneiric main restricted universe multiverse
deb-src http://ports.ubuntu.com/ oneiric main restricted universe multiverse
With the chroot base system now setup one can use schroot/dchroot to chroot into the base system and install any other packages like a regular chroot. If you want to debootstrap to install a chroot to build packages one needs to just pass the --variant=buildd option to debootstrap in step 3.
[1] http://wiki.debian.org/EmDebian/CrossDebootstrap
Labels: arm, chroot, oneiric, pandaboard, ubuntu
