[Google Chromecast] Mape0661:
How to install chrooted Debian 7.8 on a Chromecast (Debcast?)

English are not my native language but I will try answer any questions

Step 1 – 5 was made on a Debian 7.8 computer (raspbian)

Step 6 – 12 was made in Chromecast shell

1.	Install debootstrap

su
apt-get install debootstrap

2. Download mini-installation for armhf with debootstrap, this will take a while.

debootstrap --arch=armhf --variant=minbase --foreign wheezy debian http://http.debian.net/debian

3. Tar the downloaded

tar -cvf debian.tar debian/

4. Send debian.tar to CC,data dir is writable

cat debian.tar | ssh root@[chromecast-ip] 'cat > /data/debian.tar'

5. ssh to chromecast

ssh root@(chromecast-ip)

6. Untar

cd /data
tar -xvf debian.tar

7. Create a start file for Chroot

vi /data/chroot.sh

#!/bin/sh

# Fix all PATH for Debian
export ROOT=/data/debian
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export HOME=/root

# remount /data. Got an error first time I loged into chroot. remount is a fix for this
# not sure if we need to do this every reboot

echo "Remounting /data"
mount -o remount,defaults /data

# Mount dev for Debian if needed
mountpoint $ROOT/dev –q
if [ ! $? -eq 0 ] ; then
echo "Mounting dev"
mount -o bind /dev $ROOT/dev
fi

# Mount pts for Debian if needed
# It's a fix for direct ssh login to chroot
mountpoint $ROOT/dev/pts –q

if [ ! $? -eq 0 ]; then
echo "Mounting ptst"
chroot $ROOT /bin/mount -t devpts -o OPTIONS devpts /dev/pts
fi

# Mount proc for Debian if needed
mountpoint $ROOT/proc –q

if [ ! $? -eq 0 ]; then
echo "Mounting proc"
mount -o bind /proc $ROOT/proc
fi

# Mount proc for Debian if needed
mountpoint $ROOT/sys –q

if [ ! $? -eq 0 ]; then
echo "Mounting sys"
mount -o bind /sys $ROOT/sys
fi

# start chroot
chroot $ROOT /bin/bash -l

8. run chroot.sh and continue with the installation, this will take a while

chmod +x chroot.sh
./chroot.sh
debootstrap/debootstrap --second-stage

9. We now got a working minimal chroot jail, almost no programs are installed, before we can install anything we need to update sources.list and add some repositories. Use http://debgen.simplylinux.ch/ to create a sources.list. I use debian mirrors for Sweden.

echo ”deb http://ftp.se.debian.org/debian stable main” > /etc/apt/sources.list
echo ”deb http://security.debian.org/ wheezy/updates main” >> /etc/apt/sources.list
apt-get update

10. Install vim and ssh

apt-get install vim ssh

11. change port from 22 to 2222 and restart ssh

vi /etc/ssh/sshd_config
/etc/init.d/ssh restart

12. Set a password

passwd

OPTIONAL

1.	Install desctop and vnc server, this will take a while and our installation will rise with 400-450M (mine using about 800M total), we only got 1.1G total to play with so be carefull which program you install. A fix to this would be to create a Yaffs2 image for loop mount and then store it on a USB drive.

apt-get install xfce4 tightvncserver

2.	Create a loginpassword to vnc, and choose if you need a guest login

tightvncserver

3.	Start vnc server, 800x600 res.

vncserver :0 -geometry 800x600 -depth 24

4.	Log into chromecast, I used a standalone RealVNC in windows and [chromecast-ip]:0 to login

5.	More info at http://elinux.org/RPi_VNC_Server

INFO

-	To exit root jail, just type exit

-	If you started sshd in root jail you can connect to it with ssh on port 2222.

-	No need to start chroot to load a program in chroot, you can start it from outside

chroot with chroot /data/debian /etc/init.d/ssh start

- you can also kill program from outside, run ps to find out ID and use kill [id]

-	Chromecast does support loop mount, but not very many filesystems

o To mount a supported filesystem use

mount myImage.img /mnt/myImage –o loop=/dev/block/loop0

o does not support ext, ext2, ext3 or ext4

o Does support yaffs2, vfat…

o supported filetypes can be found in cat /proc/filesystems

o yaffs2utils can be compiled in debian (on CC), this program can make same filesystem type as /data, and this file can be loop mounted

o Install git, gcc and make. Then git clone https://github.com/justsoso8/yaffs2utils

Errors:

-	stdin is not a tty. Run inside chroot jail:

/bin/mount -t devpts -o OPTIONS devpts /dev/pts

or outside chroot run

chroot /data/debian /bin/mount -t devpts -o OPTIONS devpts /dev/pts

. Then try to connect to port 2222 again.

-	do this: mount -t proc proc /proc.

Run (outside chroot)

mount -t proc /proc /data/debian/proc

-	Chroot and vi can be found in busybox (busybox chroot, busybox vi) you can create a symlink to it.

mkdir /data/bin & cd /data/bin
ln /bin/busybox –s vi
ln /bin/busybox –s chroot
export PATH=/data/bin:$PATH

o	If you need Busybox it can be downloaded from: http://www.busybox.net/downloads/binaries/latest/busybox-armv7l

TODO:

-	Autostart chroot on boot

-	Does anyone know how to view shell via HDMI?

- Can keyboards and mouse be connected via a USB hub so we can use CC as a minimal computer?

LINKS:

http://www.hjackson.org/blog/archives/2008/10/18/ssh-stdin-is-not-a-tty

https://wiki.debian.org/ChrootOnAndroid

http://www.cyberciti.biz/faq/how-do-i-compress-a-whole-linux-or-unix-directory/

http://elinux.org/RPi_VNC_Server

http://debgen.simplylinux.ch/

https://bitbucket.org/inkubux/cubox-i/wiki/Plex Wheezy

https://help.ubuntu.com/community/BasicChroot

https://github.com/justsoso8/yaffs2utils

http://www.busybox.net/downloads/binaries/latest/busybox-armv7l

Screenshot:

[IMG="Debcast small"]http://i.imgur.com/GzGIM9C.png[/IMG] [IMG="small"]http://i.imgur.com/jWjrB5n.png[/IMG]g

Click for large