Scratchbox installation under 32-bit chroot on 64-bit Ubuntu

0.00 avg. rating (0% score) - 0 votes

I wanted to try out the Maemo SDK for Nokia 770, N800 and N810 devices (for some reason I happen to own one of every generation), but found out that there are no prebuilt packages for the 64-bit environment. The quick (?) remedy for this is the chroot jail, because a guest i386 environment can pretty easily be bootstrapped inside a 64-bit one. Here are the step-by-step instructions for doing it.

Setting up the chroot jail for Scratchbox

The first thing to do is setting up a chroot environment with 32-bit binaries. This can be achieved nicely with schroot and debootstrap, which can be found in the Debian Universe. Debootstrap will download and install a basic Debian system into a directory. In this case, we will install Ubuntu Gutsy i386 under /ubuntu32:

That last command will actually chroot you into the directory /ubuntu32. What that means in practise is that your new root directory will be in fact /ubuntu32, and your new shell will be restricted under that directory. In effect, what you see as the root directory / will in reality reside under /ubuntu32. There is no easy way to see whether you’re inside a jail or not, and the purpose of this is of course to trick programs into thinking they are running on another system. To escape the chroot jail, just say exit.

The newly bootstrapped system is very bare. Indeed there is no locale support until you install it. That should probably be the first thing to do. My locale is Finnish, so I will install the language-pack-fi package. After that, let’s install the Nano editor, and edit our Apt sources:

I make the sources.list look like this:

A couple more things to do before our chroot is ready. We must set up user accounts and mounts. If you are happy running as the root user, there is no need to do anything, but I wanted to add an account for myself. The easiest way is to copy all necessary information from your existing /etc outside the chroot:

That way your password, groups and all other settings are preserved without problems. You can add that command to cron if you want them synchronized automatically.

Next, you need to mount a couple of filesystems to make things go smoothly. Such are /proc, /sys and /dev, and also possibly /home and /tmp. The first three are needed for correct operation of many programs, while the latter two will ease your use of the chroot environment.

The create the mounts, add these lines to the /etc/fstab OUTSIDE the chroot (your normal fstab):

I mounted them right away with the mount -a command.

The last thing to do is make the chroot accessible for the general user. This is where schroot comes into play. It’s purpose is to make normal users able to chroot themselves into jails predefined by root. Let’s add a chroot jail into /etc/schroot/scroot.conf:

Now, user mkortela is able to chroot into our new environment:

Now we are in the chroot jail as ourselves, and able to sudo as we were outside the jail. Also, the user’s home directory is right where it is supposed to be. To remember we are inside the chroot, it may be a good idea to change the prompt a little bit:

Scratchbox installation inside the chroot jail

The Scratchbox installation will go pretty much like described in the INSTALL.txt. There are a couple of extra tweaks, though. First, lets fetch the installation scripts, and run them. First the Scratchbox installation, then the SDK installation. The installation scripts will have to be cheated with the linux32 command:

Let’s do what they ask:

And let’s create the group outside the chroot and add ourselves there as well:

And now, the SDK installation:

I installed with the default options, although I decided to download the non-free Nokia packages as well.

Installing and running Xephyr

Xephyr can be installed directly from the universe. We will install it outside the chroot environment, because that’s where all our X libraries and fonts are:

Let’s check that it runs as a regular user:

You should get a Window with a simple X session (just the default boring wallpaper and nothing else). To start the Maemo default programs in it, open another shell window, go inside the chroot, and run:

You should be able to see a very basic Maemo session, similar to the one shown in the Maemo 4.0 Tutorial. That document is also a good place to continue from here on.

8 thoughts on “Scratchbox installation under 32-bit chroot on 64-bit Ubuntu”

  1. Hi,
    and thanks for the guidelines. While installing this I noticed a couple of commands I had to modify a bit in order to succeed. Probably typos…

    The debootstrap command should be

    debootstrap –arch i386 gutsy /ubuntu32

    (two hyphens before arch instead of one)

    And schroot command should be

    schroot -c ubuntu32

  2. Well, Wordpad seems to ruin the command syntax. Anyway, ther should be TWO hyphens before arch…

  3. Cleaner way to signalize you are in chroot is to do

    $ echo “ubuntu32” > /etc/debian_chroot

    in the chroot. So if you have the default .bashrc and the ${debian_chroot:+($debian_chroot)} magic in your PS1, it will display “(ubuntu32)” (== the contents of /etc/debian_chroot) before your normal prompt when you’re in the chroot.

  4. Thanks for the information you have provided in the blog. Everything went fine with me, and I got stuck here. Hope someone has answer to this.

    $ linux32 sudo ./

    This script will install Scratchbox 1.0.11 ‘apophis’ release to your computer.

    Install options

    Install from packages=apt
    Scratchbox install path=/scratchbox
    Scratchbox group=sbox
    armel compiler=cs2005q3.2-glibc2.5-arm
    i386 compiler=cs2005q3.2-glibc2.5-i386
    armel devkits=perl:debian-etch:maemo3-tools:cputransp
    i386 devkits=perl:debian-etch:maemo3-tools
    armel CPU transparency=qemu-arm-0.8.2-sb2

    Checking for prerequisites

    Running as user root… yes
    Not running as user root inside fakeroot… yes
    Running outside of scratchbox… yes
    Running on Linux kernel… yes
    Running on i386 architecture… yes
    Host kernel binfmt_misc support… no
    E: Host kernel module binfmt_misc is required for the CPU transparency feature.

  5. The problem still remains. Can someone guide me through on what next with this

    Host kernel binfmt_misc support

  6. try to recompile kernel with enabled
    Executable file formats/Kernel support for misc binaries

Leave a Reply