Chip9$ How to install a chroot Debian tree

Da raspibo.
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

On your Debian running computer type: (It should also work on Debian derivatives like Ubuntu)

debootstrap --arch armhf --foreign --variant=minbase jessie jessie-minbase-arm http://ftp.it.debian.org/debian/

this command creates a armhf debian tree in the subdir named "jessie-minbase-arm"

Then tar and send the dir on the chip9$:

tar cvf jessie-minbase-arm.tar jessie-minbase-arm
scp jessie-min-arm.tar 10.1.1.2:/home

(10.1.1.2 is the IP address of my chip9$ wifi interface, put the proper value for your installation).

Now login to Chip9$ (e.g. using "ssh root@10.1.1.2"). and de-tar the tree.

cd /home
tar xf jessie-minbase-arm.tar

now create some files:

echo nameserver 8.8.8.8 > /home/jessie-minbase-arm/etc/resolv.conf
echo deb http://ftp.debian.org/debian jessie main > /home/jessie-minbase-arm/etc/apt/sources.list
cat > /usr/local/bin/startchroot << ENDTAG
mount --bind /proc /home/jessie-minbase-arm/proc
mount --bind /dev /home/jessie-minbase-arm/dev
mount --bind /dev/pts /home/jessie-minbase-arm/dev/pts/
chroot /home/jessie-minbase-arm /bin/bash
umount /home/jessie-minbase-arm/dev/pts
umount /home/jessie-minbase-arm/dev
umount /home/jessie-minbase-arm/proc
ENDTAG
chmod +x /usr/local/bin/startchroot

Now everything is ready to enter the chroot environment:

startchroot

The prompt may appear something like:

I have no name!@chip:/#

Now the installation must be finalized inside the chroot tree:

DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C /debootstrap/debootstrap --second-stage

Now Debian is ready. It is possible to update the list of available packets and install all what you need.

apt-get update
apt-get install aptitude
aptitude install vim build-essential
aptitude install python python3

It is possible to add a user:

adduser user

To "become" the user type:

su user
cd

It is possible now to run the well-known "hello world" test (cat is to try the test using cut&paste, use vim if you like:

cat >hello_world.c <<ENDTAG
#include <stdio.h>
int main(int argc, char *argv[]) {
        printf("hello world from CHIP!\n");
}
ENDTAG
gcc hello_world.c
./a.out

The answer is:

hello world from CHIP!

If you exit from the chroot shell, you'll return in the standard busybox-based image environment currently available for flashing Chip9$.

Next time you boot chip9$, type:

startchroot

to enter the Debian chroot.