Qball's Weblog

If you need to easily switch between 32bit and 64bit?

Tags General 

Today I dug up some old software, where I want to re-use a certain part, shamefully it uses a library that is 32bit. (But is the only library I know off that can do this things, this nicely (shamefully not free)).

But I did not want to setup a 32bit virtual machine and be forced to copy files from one point to the other and back all the time. So I setup a a chroot.

I will now quickly describe the steps I took. I post them here, because many manuals I found on the internet had errors in them (I probly will have to) or used old config formats.

Installing the required software

The software I am going to use is: *schroot. *I use debootstrap to install the 32bit linux environment.

?View Code BASH
1
sudo apt-get install schroot debootstrap

Installing 32bit ubuntu using debootstrap

First create a directory to store the distro in, preferable outside your home directory. I used /Storage/chroot/

?View Code BASH
1
mkdir -p /Storage/chroot/natty32/

Now debootstrap natty in here:

?View Code BASH
1
sudo debootstrap --arch i386 natty /Storage/chroot/natty32/ http://ftp.tudelft.nl/archive.ubuntu.com/

This will take 2 minutes or so. (depending on internet and hard-disk speed).

Configuring SCHROOT

Now this is going to be the ‘hardest’ part. Edit /etc/schroot/schroot.conf and add the following section.

?View Code INI
1
2
3
4
5
6
7
8
9
[natty32]
description=Ubuntu natty
directory=/Storage/chroot/natty32/
users=qball
groups=users
root-groups=root
personality=linux32
script-config=desktop/config
type=directory

Switching to 32 bit

To switch to the 32bit environtment, just type the following command:

?View Code BASH
1
schroot -c natty32

You see that your promt says (natty32)username@host:~$, this means your now in your 32bit environment. (type uname -a to verify).

But you are still in your own home-directory, with access to all your files!

 

Installing software, to make it usefull

Warning, the debootstrapped linux is very very basic, so you need to install a lot of extra tools (like vim, build-esssentials, sudo)

First we install sudo:

?View Code BASH
1
2
3
4
5
sudo schroot -c natty32
 
(natty32)root@host:~qball$ apt-get update; apt-get install sudo vim
 
(natty32)root@host:~qball$ exit

With sudo installed you can just do (as normal user) sudo apt-get install  inside the 32bit environment.

You might also want to enable multiverse, universe and restricted repository in /Storage/chroot/natty32/etc/apt/sources.list.

deb http://ftp.tudelft.nl/archive.ubuntu.com natty main restricted universe multiverse
deb-src http://ftp.tudelft.nl/archive.ubuntu.com natty main restricted universe multiverse

 
And that is all there is to it. This way you can very easily switch between 64/32bit, if you want even different versions of ubuntu. (but you will still use the same kernel and drivers!!)