Home > Linux > Creating chroot for arm on Ubuntu with rootstock

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 config.sh /mnt

Go back to your chroot and then:

chmod +x config.sh
./config.sh

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 config.sh 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:

exit
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

Share
  1. August 18th, 2010 at 12:57 | #1

    I am never able to make The ubuntu image. Can you upload your image here?
    Thanks
    I keep on failing at step 2

  2. admin
    August 19th, 2010 at 03:31 | #2

    @Aditya Talpade
    Will see what I can do.

    EDIT: I have added an dowload link to an img.

  3. August 19th, 2010 at 21:13 | #3

    Thanks for the image.

  4. yousef
    August 23rd, 2010 at 17:59 | #4

    Please reupload link!!

  5. admin
    August 24th, 2010 at 08:27 | #5

    @yousef
    Why the download link seems to work?

  6. Spook
    September 9th, 2010 at 16:50 | #6

    I’m trying to, but failing to understand fully the steps that you describe here… I was wondering if it was possible to build an Ubuntu image for the Jolicloud OS? I think that or the Ubuntu Netbook edition may be more suitable for the Galaxy’s small screen.

  7. jos
    October 1st, 2010 at 09:18 | #7

    thnx, works great, amazing! Any way of resizing the image after created?
    (1G turned out to be a bit small) Also on my phone, i don’t have resize2fs.

  8. jos
    October 1st, 2010 at 18:02 | #8

    found it (case anyone is interested): uec-resize-image !

  9. jos
    October 1st, 2010 at 21:54 | #9

    Maybe you like this idea: the galaxy has no physical keyboard. But how about opening a full screen virtual keyboard (xvkbd) on top of all other windows and making the keyboard transparent. I tried this using transset-df but apparently vnc isn’t able to display transparency (keyboard stays opaque) Any ideas?

  10. PRScott
    October 3rd, 2010 at 15:20 | #10

    Hi, great stuff here. Does your image already include the config.sh and/or modified .bashrc file?

    I was trying to mount it on my 10.04 laptop but when I get to the chroot commands, I get errors about not finding /bin/bash.

    Thanks!

  11. admin
    October 6th, 2010 at 11:50 | #11

    @jos
    Thank’s for the tip for resizing. You can also create your own image and copy the files there.

    Sorry can’t help you with keyboard.

  12. admin
    October 6th, 2010 at 11:53 | #12

    @PRScott
    No the bashrc is not edited on my img and it does not contain the config.sh

    You can download it from http://files.coralic.nl/ArmChrootUbuntu/config.sh

  13. jos
    October 9th, 2010 at 06:22 | #13

    Some tips for usability:

    Controlling the mouse in androidvnc is quite difficult. Check out the *pocketcloud* app. This is also a vnc client for android. It has kind of a virtual mouse built in which allows accurate control of the mouse pointer despite the drawbacks of a capacative screen. It also provides a quick way to pop up a keyboard for entering text into an application, without an intermediate text box appearing as in androidvnc, and it has ctrl/alt/tab/arrow keys.

    Another app I use is the dingul hangul keyboard, which has most special symbols that are nice to have in a terminal (as | / *etc) available *without cycling* trough alternate keyboards. The alternate symbols are accessed by pressing a key and sliding left/right/top/down to select. (Drawback: the app is available only in korean, but there is a qwerty keyboard).

    josvanr

  14. jos
    October 9th, 2010 at 07:14 | #14

    Q: any way to mount my /sdcard from within the ubuntu image?

  15. jos
    October 10th, 2010 at 06:58 | #15

    (case anyone wants to know) A:

    create directory /phone within your ubuntu image

    then from outside your ubuntu image:

    busybox mount -o bind /sdcard /data/local/mnt/phone

    I was unable to mount the entire phone (mount -o / /data/local/mnt/phone) for some reason..

    josvanr

  16. aadrujinin
    October 20th, 2010 at 05:16 | #16

    [: not found
    test: not found
    mkdir failed for /data/local/mnt, File exists
    ioctl LOOP_SET_FD failed: Device or resource busy
    mount: Device or resource busy
    mount: Device or resource busy
    chroot: not found

    Help please!!!

  17. Alex
    April 2nd, 2011 at 19:27 | #17

    sudo mount -o loop IMG-FILE_NAME /mnt ….I have some problems here..it sais that there’s no such file or directory.What should I do…what is the image file name.Thanks in advance!

  18. admin
    April 7th, 2011 at 03:29 | #18

    @Alex
    the replace the IMG-FILE_NAME with your own img name. If I remember corectly it should be something like qemu-armel-TIMESTAMP.img

    The img is in the folder that you run the rootstock command in.

  19. bernabap
    April 19th, 2011 at 01:45 | #19

    My lxterminal is loading without promt! Cant write nothing on it! Any idea what is going on?

    Thanks

  20. payman
    May 12th, 2011 at 09:11 | #20

    hello
    thanks …
    I have one problem with ssh . how login to the chroot envaroment?
    after mount and chroot , I send (/#ssh root@localhost) and empty password but can`t login to chroot envaroment. I read 100 webpage about ssh but can`t use it!!!
    excuse me for bad english.agan Thanks for your good sit.

  21. Peyman
    May 21st, 2011 at 22:37 | #21

    Hello,
    everything gone well, but almost at the end of creating the image, I receive an error which says a java certificate needed. do i need a specific version of java sdk, etc, or the error belongs to something else.
    thanks.

  22. Jim
    December 15th, 2011 at 02:05 | #22

    What’s the root password that you set in the image ?

  1. August 17th, 2010 at 16:26 | #1
  2. August 23rd, 2010 at 03:06 | #2
  3. August 23rd, 2010 at 03:52 | #3
  4. August 25th, 2010 at 05:38 | #4
  5. November 5th, 2010 at 02:12 | #5
  6. May 11th, 2011 at 15:39 | #6
  7. October 17th, 2011 at 08:27 | #7