How to Build CHROOT ARM Ubuntu Images for Android!

This is for those of you who want to learn how to build your own CHROOT ARM Ubuntu images for Android from scratch.

Why? Β For example, perhaps you might want to include certain programs like SSH, Web server, etc…etc… so the Ubuntu image you ultimately end up using on your Android device will not have stuff you don’t want/need.

Also, this is actually a great way to learn about the whole process of running ARM Ubuntu on your Android device whether it be a smartphone or tablet.

How to Build CHROOT ARM Ubuntu images for Android

*Note – This guide will work on all ARM-architectures of Android including TI-OMAP, Samsung Hummingbird, and Qualcomm, so long as they are ARMv7 architecture. (e.g. Nexus One, HTC Evo 4G, Droid X, Droid 2,Samsung Galaxy S, etc…etc…)

1) First, you will need to a Ubuntu system 9.10 (karmic) or later, I used Ubuntu Lucid Lynx 10.4 on my Intel Core i7 desktop. *Actually running that of VirtualBox on my Windows 7 64-bit.

2) Open up a terminal on your Ubuntu system.

3) Let’s make an ARM Ubuntu image using Rootstock command:
sudo rootstock \
--fqdn ubuntu \
--login ubuntu \
--password ubuntu \
--imagesize 4G \
--seed linux-image-omap,build-essential,mysql-server,tightvncserver,lxde,mysql-server-core-5.1,mysql-server-5.1,libmysqlclient16,mysql-common,mysql-client-core-5.1

Here, you can set login/password to your liking, image size, and also different programs you want installed beforehand. You can always use apt-get to install more packages after you CHROOT.

You should end up with a file like armel-rootfs-201101311759.tgz with the datestamp of the time you ran the command.

4) Let’s make an empty image file with command, “dd”:

dd if=/dev/zero of=ubuntu.img bs=1MB count=0 seek=4096

Here, you can change the seek parameter to how big of an image file you want to make. I have it set to 4096, which is 4GB. If you want smaller or larger, change this value accordingly. E.g. 8192 for 8GB.

5) Next, we are going to format the image as ext2/ext3 filesystem so it can be compatible with our Android OS:
mke2fs -F ubuntu.img

6) Next, we will mount the empty image file to directory /mnt:
sudo mount -o loop ubuntu.img /mnt

7) Next, we will uncompress (untar) the ARM image we made earlier into the /mnt directory:
sudo tar -C /mnt -zxf armel-rootfs-200904151837.tgz

8) Once all the files are copied over, we simply unmount the image file and we are ready to rock and roll (or copy it over to your Android device)!
sudo umount /mnt

9) If you have trouble installing software using apt-get after you made this image, try installing it under CHROOT on your Ubuntu (not Android) by using QEMU user mode emulation.

References


ARM RootfsFromScratch – This is a great place to start on learning to build ARM Ubuntu images for Android. Β  Just make sure to use “mke2fs” instead of “mkfs.ext4” as Android currently doesn’t support ext4 file system type (as far as I know and I’ve tried).

Join the Conversation

24 Comments

  1. Would you be able to do this for puppy linux?

    as an aside, do you install the OS on the memory card or phones onboard memory? How do you remove the installation? Thanks

  2. Sorry i’m newbie in linux. Could you please tell more detail step about doing this. I’ve follow the above steps, it always display the file is not exist after run command sudo tar -C /mnt -zxf my-file-name.tgz

    Anyone give me the link to download the compiled ubuntu version for Galaxy Tab P1000 ?
    Thanks

    1. hi , i meet the question also , maybe you are using a ubuntu 11.10 X86-64 as me
      i get the same mesgen , because the exec file system is for arm v7
      but the ubuntu.img the website servered was arm v7,
      so i can chroot by using the ubuntu.img but i can’t chroot using my own ubuntu.img …
      pleased for you reply

  3. Good job on the how to. I would recommend using remix as it is designed for light weight devices such as tablets and netbooks. As a suggestion, to resolve the keyboard issue, use orca and have it display the gnome on screen keyboard. You can set it up while you are chrooted in, and it will auto launch every time you remote in to the environment. This will remove the complication of the VNC app, or extra hardware such as keyboards and mice and make the tablet function more like a native tablet should.

      1. Not sure if remix is supported for ARM, Android runs on ARM processor so you have to get ARM-versions of Ubuntu.

  4. Great guide!

    I did have a problem when running this, though – the desktop environment failed (inappropriate ioctl) for almost every application.
    What should be in the mount table? Can I use the regular unionfs file?
    Mine contains:
    busybox insmod unionfs
    mount -t unionfs -o dirs=$mnt/etc=rw:/etc=ro unionfs /etc

    mount -o remount,rw /
    ln -s $mnt/lib /

    for x in \
    bin boot home media mnt \
    opt selinux srv usr var
    do
    ln -s $mnt/$x /
    done

    rmdir /root
    ln -s $mnt/root /
    mount -o remount,ro /

    mount -t unionfs -o dirs=$mnt/sbin=rw:/sbin=ro unionfs /sbin
    mount -t unionfs -o dirs=$mnt/dev=rw:/dev=rw unionfs /dev
    mount -t devpts devpts /dev/pts

  5. Hi,

    What about Armv6 ? (Galaxy 551). Is there a way to chroot and launch ubuntu 10.10 also ?
    Thank’s

  6. Just in response to an earlier question, there is an arm version of the remix. I’ve been using it on a beagle dev board.

    1. You say it exists.. You would make it easier for all the others if you’d post some sort of info about it πŸ™‚

  7. I was wondering if your ARM root would work on a Tegra 2 dual processor? That is what I have in my elocity 7a 7 inch tablet running a root android 2.2 from the XDA site.

  8. i have (HUAWEI u8110) i want to create puppy linux rom for it
    but i want help so please mail me with guide or with pre-made rom of linux puppy

  9. Hi!

    This is great as I could not get adobe flash to work on my phone Samsung Galaxy Mini.

    Everything great… installed and can run in androidvnc! πŸ™‚

    Only one problem, the Samsung onscreen keyboard does not work… if I type ‘A’ I get something different… and the same for all other keys. The mouse works great!

    Is there a solution? The keyboard works fine in the terminal emulator for bootubuntu script but not in androidvnc in the ubuntu gui!

  10. I now have the solution for no keyboard on cellphones!

    Use the ubuntu on screen keyboard program Cell Writer. Onboard and others did not work.
    Thanks for your great work!

  11. This is a great tutorial ! Also your tutorial on getting Ubuntu on a Galaxy Tab 10.1 was easy to follow and implement !

    I am have one problem in making an image (both oneiric and natty) to run on Galaxy Tab 10.1. I can do the rootstock and create the image (actually I am creating the image using a virtual machine – virtualbox, Oneiric) and can get it to boot in the GT 10.1.

    Once booted on the GT 10.1, I installed lxde and firefox and thunderbird (I could not get Unity to work). I had to do one hack to get the apt-get updates and installs to work properly which I found at http://forum.xda-developers.com/archive/index.php/t-1235430.html.

    dpkg-divert –local –rename –add /sbin/initctl
    ln -s /bin/true /sbin/initctl
    dpkg –configure -a

    The problem is that both firefox and thunderbird crash when starting. I can not see any useful information either from running it from a terminal or looking at the crash report. The Notes say “GLXtest failed (exited with status 1): glx extension missing”

    I have tried with rootstock a natty and oneiric release as well as downloaded the ac100 and OMAP4 preinstalled images from Ubuntu (which I transferred to an image by this instructions in the prebuilt kernel section). All have the same problem that firefox and thunderbird crash immediately when opened (thought you do see the program window open just before the crash report comes).

    Your prebuilt Karmic ubuntu in the Ubuntu on GT 10.1 instructions works fine and both firefox and thunderbird open fine.

    There must be some fine tuning settings I have to do in the image. Anyone know how I can solve this or trace where the problem can be ?

  12. 9) If you have trouble installing software using apt-get after you made this image, try installing it under CHROOT on your Ubuntu (not Android) by using QEMU user mode emulation.

    Could you give me some instructions for this? I’m a bit lost.

  13. hi ,my OS was ubuntu X86-64 desktop…
    i did as you said , but when i chroot it goes wrong ,
    i chechked , i finally found the exec program in the ububtu.img was arm 7 file ? ?
    How could it be ?
    the program couldn’t exec exactlly ….
    Is there something wrong ???

  14. I all , and thank you for your howto.
    I’m a neebee in linux, and I’ve somes questions.
    When I’ve finished, I must do copy all file in /sdcar/tmp ?
    After in My phone (galaxy s2) what is the command or script to run my linux?

    How I can greate a .img compiled ?
    Excuse me for my poor English.
    Thank you

Leave a comment

Your email address will not be published. Required fields are marked *