Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

HOWTO set up a 32-bit chroot in AMD64 the easy way

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
hkoster1
Posts: 1264
Joined: 2006-12-18 10:10

HOWTO set up a 32-bit chroot in AMD64 the easy way

#1 Post by hkoster1 »

Many users of 64-bit Debian GNU/Linux also (still) have a 32-bit version of the OS installed. One reason may be that some programmes are not yet ported to 64-bit, or don't yet have the full functionality in 64-bit. Multimedia programmes requiring special codecs and plugins (Flash, Shockwave) come to mind; their use would force one to "adulterate" an otherwise pure 64-bit system with 32-bit libraries and wrapper programmes. So, this HOWTO is for those who (1) want to run a pure 64-bit system; or (2) want to run favourite programmes installed in their old 32-bit OS but not (for any reason) in their new 64-bit OS.

This HOWTO describes an easy way to run any programme installed in the 32-bit OS in a chroot jail running under the 64-bit OS. It is so simple to implement that people might even consider installing a new 32-bit OS for exactly that purpose in a spare partition (don't even think of messing with debootstrap).

I'm running Debian Sid in both 32- and 64-bit versions, but clearly Etch or Lenny will do just as well. I do recommend, though, that you run the same distro in both cases, dist-upgrading one of them as needed. I'll use Etch in the examples below, change that to Lenny or Sid as appropriate. My 32-bit OS root partition is /dev/sda8, change that also to match your installation.

The following setup must be run from the 64-bit OS. All commands prefixed with # are to be run as root; user commands use $.

Mount points
First make a mount point for the 32-bit root partition,

Code: Select all

# mkdir /mnt/etch32
and edit /etc/fstab by adding the lines

Code: Select all

/dev/sda8         /mnt/etch32                       ext3   defaults    0  0
/home             /mnt/etch32/home                  none   bind        0  0
/tmp              /mnt/etch32/tmp                   none   bind        0  0
/media/cdrom0     /mnt/etch32/media/cdrom0          none   bind        0  0
/dev              /mnt/etch32/dev                   none   bind        0  0
proc-chroot       /mnt/etch32/proc                  proc   defaults    0  0
A separate boot partition for 32-bit Etch, if you have one, need not be mounted. The new additions are mounted with

Code: Select all

# mount -a
which will also happen automatically at boot from now on. Note that several directories of the 64-bit host OS have been mounted in the chroot, taking the place of similarly named directories in the 32-bit OS.

This completes the setting up of the chroot, what remains is making it simple to use.

Schroot users
Install the schroot package with

Code: Select all

# apt-get install schroot
and configure it by editing /etc/schroot/schroot.conf to contain the following minimal contents:

Code: Select all

[etch32]     # some name for the chroot environment
description=Etch 32-bit chroot
location=/mnt/etch32
aliases=default
personality=linux32
priority=1
users=henk
Of course, you should substitute your own user name.

How to use
Schroot allows the user to run any programme in the 32-bit OS from the 64-bit OS without ever having to enter the chroot. What's more, this can optionally be done with the current 64-bit environment (as in /etc/profile) preserved. For example,

Code: Select all

$ schroot -p iceweasel
starts the 32-bit version of IceWeasel with the user's own settings (bookmarks, etc) for the 64-bit version (provided that IceWeasel is installed in the 32-bit OS). Next, hit on a site playing Flash content or content encoded with w32codecs, and all should be well if it already was set up properly in the 32-bit OS to start with. Note that any changes made inside IceWeasel, like added bookmarks, will also carry over to the 64-bit version of this programme.

Note that maintenance of the 32-bit OS can also be done this way,

Code: Select all

# schroot apt-get update
or even with

Code: Select all

$ sudo schroot apt-get dist-upgrade
so there's no need to shutdown the 64-bit OS and reboot into the 32-bit OS to do so.

We'll leave it to the reader as an exercise to provide icons on the 64-bit desktop that will start 32-bit IceWeasel, Kaffeine, Mplayer, etc, this way.

Removing the chrooted environment
This must be done with care, since some regular directories in the host OS (like /home) are bound to it -- these should not be removed inadvertently! The proper way to remove the chroot environment is by first removing the added lines in /etc/fstab (see above), and then to reboot. Let's hope you do this because Debian GNU/Linux has become fully multi-arch bootable and/or all the multimedia programmes and codecs have become fully functional in 64-bit (that'll be the day...).

Have fun!

Acknowledgements: I started with the Howto by michael7, see http://forums.debian.net/viewtopic.php?t=12061, and consulted recursively the sources listed there. Those sources say that the system libraries of the 32-bit OS should be linked with those of the host 64-bit OS, but this is clearly not needed if all you want to do is run 32-bit programmes in a chroot jail. I have also upgraded from dchroot to schroot. Consult michael7's Howto if you can't solve the icon exercise...

Edited 13 August 2007: rewrote the introductory paragraphs, no changes to the code.

dmn_clown
Posts: 522
Joined: 2006-12-03 23:40

#2 Post by dmn_clown »

It is also possible to skip editing /etc/fstab and use schroot to mount and umount depending on how you configure schroot. See: man schroot and man schroot.conf for more details.

hkoster1
Posts: 1264
Joined: 2006-12-18 10:10

#3 Post by hkoster1 »

Good point! I'll leave the details as an exercise... :wink:

Post Reply