Apr
05
2012
Create a 32bit chroot enviroment inside your 64bit archlinux

As you may already know, you can install a 32bit linux distribution into a 64bit machine.

Many people are keep telling me, that they are still using a 32bit installation cause of some (not always opensource) applications which havent yet built up for 64bit kernel.

Lately i came into a same experience, when trying to access my android mobile through a usb, using google’s android platform tool: adb.

Android SDK has only a 32bit flavor.

Many distros support multi-lib (libraries) repositories that you can add to your linux box and use 32bit libs & applications inside your 64bit installation.

Of course this method isnt only for 32bit but also if you want to have different versions of the same shared object and dont want to rebuild your packages.

I find this method a lot messy and i dis-approve setups like that.

The alternative method is to use GNU’s core utility: chroot.

Change root directory (run command or interactive shell with special root directory) is extremely easy to setup. Till now perhaps you have listened that chroot is to jail exposed services, but in fact you can build your own environments for clean development or testing applications or whatever you have thought.

You dont even need to have an extra partition or even reboot your linux box!

The archlinux package manager aka pacman has a “root device” parameter so in fact you can create a new chroot archlinux enviroment like adding a new package in your existing linux box!

With the below script you will setup a new 32bit enviroment into your archlinux machine:


export ROOT=/arch32

mkdir -pv $ROOT/var/cache/pacman/pkg/ $ROOT/var/lib/pacman/

pacman -v --arch i686 -r $ROOT --noconfirm -Sy base

mount --bind /dev $ROOT/dev
mount --bind /proc $ROOT/proc
mount --bind /sys $ROOT/sys

chroot $ROOT

If you need to open gui apps from your chroot env, you must type:


xhost +

from your primarly OS.

Tag(s): archlinux, chroot