Creating chroot for arm on Ubuntu with rootstock

Some of you may or may not be familiar with chroot, for those who are familiar with chroot good job and for those that aren’t shame on you. Just kidding please read this for some more info about chroot.
Now that we all know what chroot is, maybe it could be fun to create an chroot environment, and to make it more exciting we are not creating an x86 but an arm processor environment :)

There are tons of ways of doing this but this is how I am doing it. You can use this method on any ubuntu from 9.04 and higher, but keep in mind I am using 10.04 so if you get error’s try to blame it on that instead off me. So first thing we need to do is prep our own ubuntu machine to be able to build a chroot environment. To do so we install rootstock, and we do it like this:

sudo aptitude install rootstock

Now we can create a chroot with rootstock, this is an simple example of no nonsense chroot:

sudo rootstock -f localhost --login ubuntu --password ubuntu --imagesize 1G --notarball

If you wish to know what this all means I recommend you to do:

man rootstock

To be able to access this chroot environment we need to mount it like this:

sudo mount -o loop IMG-FILE_NAME /mnt
sudo mount -t proc proc /mnt/proc

Now we can enter our chroot:

chroot /mnt /bin/bash

Or exit it and umount it like this:

sudo umount proc 
sudo umount /mnt

So here you go small simple way of creating a chroot environment. Is that all you may ask your self, no it’s not, what we actually have created here above is a empty non fun chroot environment. So instead of that let’s try to make something more fun and exciting like have access to internet, have ssh server running, have an vncserver running. Here are the steps in how to do this.

Step 1, Create the image containing ssh tightvncserver lxde

sudo rootstock -f localhost --login ubuntu --password ubuntu --imagesize 1G --notarball --dist lucid --seed ssh,tightvncserver,lxde,expect

Step 2, Start the chroot environment. You can use my script from here or do this:

sudo mount -o loop imgNAME /mnt
sudo mount -t proc proc /mnt/proc 
sudo mount -t devpts devpts /mnt/dev/pts
sudo su -c 'chroot /mnt /bin/bash'

To be able to use SSH or VNC you need to configure some things. I have created an script that can do this for you, you can download it from here.

Step 3, Configure:
Open an new terminal and then:

sudo cp /mnt

Go back to your chroot and then:

chmod +x

Step 4, If you want to use SSH or VNC you will need to start those every time you login to your chroot. You can do this by running these command’s

vncserver -geometry 800x600
/etc/init.d/ssh restart

OPTIONAL: You can also add these commands to your bashrc script so that they will be executed for you. You can do this by running this, if you haven’t run step 3 yet you can also uncoment these two lines from my script.

sed -i '1i vncserver -geometry 800x600' /root/.bashrc 
sed -i '1i /etc/init.d/ssh restart' /root/.bashrc

Step 5, To quit the chroot just do the following or use my script from here:

sudo umount /mnt/dev/pts 
sudo umount /mnt/proc 
sudo umount /mnt

You all are set now, you have an arm ubuntu image and you have configured it all that is left to do is use it.

As always there are people I would like to give credits to, and this time it’s Nexus One Hacks.

UPDATE For those who don’t like to do all this here is an img I created: Download