Install bundled 32-bit system in 64-bit system

From ArchWiki
Revision as of 18:23, 2 March 2011 by Mreschke (Talk | contribs)

Jump to: navigation, search

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

This article is for those who really need to run 32-bit applications with easy installation. As Arch64 tries to be a pure 64-bit distribution, it is likely the developers will not provide any compatibility libraries, so this system seems to be the cleaner solution.

Before proceeding:

  • Note that this script's author is not an expert so there may be errors.
  • This script also does not change anything outside the 32-bit directory. However, you will be creating hard links to your base system's configuration files and also mounting your home and other directories inside the 32-bit install directory. Thus, mistaken settings in the linked configuration files or carelessly removing all or part of the locally mounted directories can inflict catastrophic damage to your base system.
  • If you have a custom kernel configuration, you need to make sure that this option is set: Template:Codeline. Otherwise, your 64-bit kernel will not be able to access your 32-bit chroot environment. The stock Arch64 kernels generally have this set properly by default.

Install the base 32-bit system

1. Create the repository:

mkdir /opt/arch32

2. Generate temporary pacman configuration files for the new repository:

sed -e 's/\$arch/i686/g' /etc/pacman.d/mirrorlist > /opt/arch32/mirrorlist
sed -e 's@/etc/pacman.d/mirrorlist@/opt/arch32/mirrorlist@g' /etc/pacman.conf > /opt/arch32/pacman.conf

These files would conflict with the normal pacman files, which will be installed in the later steps. For this reason they must be put into a temporary location (Template:Filename is used here). Once you have finished installing the new system and are ready to run pacman under the chroot environment, you can remove them.

As soon as you use the Template:Codeline switch in the pacman command below, files Template:Filename and Template:Filename will be created inside Template:Filename. The pacman log will be Template:Filename and will not interfere with your 64-bit installation. There is no need for a Template:Codeline directive in Template:Filename or a Template:Codeline switch unless you want the log file to be elsewhere.

The Template:Codeline switch is for the package to be cached in the Template:Filename directory instead of Template:Filename.

Use the Template:Codeline switch to tell pacman to use the configuration file ganerated above, rather than Template:Filename.

3. Create the directory, just to be sure:

mkdir -p /opt/arch32/var/{cache/pacman/pkg,lib/pacman}

3b. Edit 'Architecture' for pacman >= 3.4

# In /opt/arch32/pacman.conf
# Architecture=auto

4. Now proceed to sync pacman:

pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -Sy

5. Install the base packages:

pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -S base base-devel

If you do not intend to compile packages inside this chroot, you can omit the base-devel group:

pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -S base

You can now optionally remove the temporary pacman configuration files. If you keep these file there, you will be able to run pacman in the base 64-bit system to manage the packages in the 32-bit repository.

rm /opt/arch32/{mirrorlist,pacman.conf}

To use the newly installed pacman, you need to uncomment some mirrors in /opt/arch32/etc/pacman.d/mirrorlist, and make any other desired changes to the new pacman installation.

Alternative lightweight install

The install method above will install a lot of packages which are not necessary in a 32-bit sub-system. Actually, the pacman package itself is not necessary -- you can always use the 64-bit version instead. This new method can help you install a smaller sub-system.

Start with the 32-bit repository:

mkdir /opt/arch32

And then the pacman configuration files. However, unlike in the previous method, these files should not be removed:

sed -e 's/\$arch/i686/g' /etc/pacman.d/mirrorlist > /opt/arch32/mirrorlist
sed -e 's@/etc/pacman.d/mirrorlist@/opt/arch32/mirrorlist@g' /etc/pacman.conf > /opt/arch32/pacman.conf

Create necessary directories for the new system. Note that Template:Filename is required here because you are not going to install dbus in the sub-system, and you would still want to access the 64-bit dbus in your 32-bit subsystem.

mkdir -p /opt/arch32/var/{cache/pacman/pkg,lib/pacman,lib/dbus}

Create an alias for pacman32, the command to be used to install 32-bit packages. Just add the following line to your ~/.bashrc or similar:

alias pacman32="pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf"

Edit 'Architecture' for pacman >= 3.4

# In /opt/arch32/pacman.conf
# Architecture=auto

Sync pacman32:

pacman32 -Sy

Install basic packages for 32-bit subsystem. These are the minimal packages that allow you to chroot to the subsystem and run Template:Codeline script for i18n.

pacman32 -S filesystem licenses bash sed coreutils gzip

Now you are ready for the following steps. Remember that you should replace all pacman commands required to run the chroot environment with pacman32 under the 64-bit system.

/etc/rc.d/arch32 rc script

To initiate the 32-bit environment at startup, create a script in Template:Filename called Template:Filename:


. /etc/rc.conf
. /etc/rc.d/functions

dirs=(/dev /dev/pts /dev/shm /tmp /home)
case $1 in
        stat_busy "Starting Arch32 chroot"
        for d in "${dirs[@]}"; do
         mount -o bind $d /opt/arch32/$d
        mount -t proc none /opt/arch32/proc
        mount -t sysfs none /opt/arch32/sys
        add_daemon arch32
        stat_busy "Stopping Arch32 chroot"
        for (( i = ${#dirs[@]} - 1; i >= 0; i-- )); do
         umount "/opt/arch32${dirs[i]}"
        umount /opt/arch32/{proc,sys}
        rm_daemon arch32
        $0 stop
        sleep 1
        $0 start
        echo "usage: $0 {start|stop|restart}"
exit 0

Then allow execution of the script:

chmod +x /etc/rc.d/arch32

And add it to Template:Filename:

DAEMONS=(syslog-ng network netfs arch32 crond)

Configure the new system

First, copy important configuration files:

cd /opt/arch32/etc

ln -f /etc/passwd* .
ln -f /etc/shadow* .
ln -f /etc/group* .
ln -f /etc/sudoers .  # note: you'll need to install sudo before creating this entry, or sudo will refuse to install

ln -f /etc/rc.conf .
ln -f /etc/resolv.conf .

ln -f /etc/localtime .
ln -f /etc/locale.gen .
ln -f /etc/profile.d/ profile.d

cp /etc/vimrc .
cp /etc/mtab .

Be sure to include the "." character.

Now chroot into your new system:

/etc/rc.d/arch32 start
xhost +SI:localuser:usernametogiveaccesstogoeshere 
chroot /opt/arch32

It is recommend that you use a custom bash prompt inside the 32-bit chroot installation in order to differentiate from the regular system. You can, for example, add a ARCH32 string to the PS1 variable defined in Template:Filename. In fact, the default Debian .bashrc prompt string contains appropriate logic to report whether the working directory is within a chroot.

Before continuing, keep in mind that the file Template:Filename from the 32-bit environment is the default one. If you have not yet uncommented some mirrors in "/etc/pacman.d/mirrorlist", you must do so, or pacman will fail with an unexpected error.

Fix possible locale issues:

pacman -S ttf-bitstream-vera ttf-ms-fonts

You can install any other font. You just need one or your applications will not display any text.

Now you can install any applications you need:

pacman -S acroread opera
pacman -S firefox
pacman -S flashplugin
pacman -S mplayer-plugin

You can also clean up to regain space by removing some unnecessary packages. This cleanup is for your 32-bit root environment and must then be done inside it. Below is a list of packages you might want to remove:

pacman -Rd mkinitcpio
pacman -R kernel26 \
grub \
dhcpcd \
rp-pppoe \
ppp \
xfsprogs \
reiserfsprogs \
jfsutils \
hdparm \
hwdetect \
syslog-ng \
logrotate \
lvm2 \
dcron \
wpa_supplicant \

Also consider regularly clearing out pacman's cache:

pacman -Sc

Executing 32-bit applications from a 64-bit environment

Install "schroot" to your 64-bit installation:

pacman -S schroot

Schroot is already configured for Arch32 chroot, so you should just check Template:Filename, section [Arch32], to check if it matches your configuration. You will also want to edit Template:Filename to match the mounts you created within Template:Filename, because applications run through schroot will not be able to see mounts not listed in Template:Filename.

Finally, to use your 32-bit applicationss:

schroot -p -- opera

It will launch Opera from the 32-bit environment.

Here is a small program that substitutes the 64-bit version of Firefox. To use it you must paste it into geany (or another program than can compile it), save as Template:Filename and compile by pressing F9:

#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main(int argc, char **argv)
    string temp="schroot -p firefox \"";
    string temp2="\"";
    if (argc>=2) temp+=+argv[1];
    return 0;

Now replace firefox binary file in Template:Filename with the compiled file. Change "3.0.1" to the appropriate version.

Java in a chroot

See Java for installation instructions.

After installing, adjust the path to get Java working:

export PATH="/opt/java/bin/:$PATH"


Compilation and installing

Ensure the desired options are set in the local Template:Filename.

Some packages may require a Template:Codeline flag be added to the ./configure script in the PKBUILD:

./configure --host="i686-pc-linux" ...

This is the case when the build makes use of values (for example, the output of the Template:Codeline command) inherited from your base system.

You may need to give users write access to your chroot's /dev/null to stop some scripts from failing:

chmod 666 /dev/null

Video issues

If you get:

X Error of failed request: BadLength (poly request too large or internal Xlib length error)

while trying to run an application that requires video acceleration, make sure you have installed appropriate video drivers in your chroot. For example,

pacman -S nvidia

Sound in flash (youtube, etc.)

To get sound from the flash player in Firefox, open a terminal and chroot inside the 32-bit system:

chroot /opt/arch32

From there, install alsa-oss:

pacman -S alsa-oss

Then type:

export FIREFOX_DSP="aoss"

Every chroot into the 32-bit system will require this export command to be entered so it may be best to incorporate it into a script.

Finally, launch Firefox.

For Wine this works the same way. The package alsa-oss will also install the alsa libs required by Wine to output sound.

Tips and tricks


Xyne has created a package that installs a minimalist 32-bit chroot as described above. More information can be found on the forum and on the project page.

Allowing 32-bit applications access to 64-bit Pulseaudio

Add these lines in Template:Filename, above Template:Codeline:

mount --bind /var/run /opt/arch32/var/run
mount --bind /var/lib/dbus /opt/arch32/var/lib/dbus

And above Template:Codeline:

umount /opt/arch32/var/run
umount /opt/arch32/var/lib/dbus

More information is available at the Pulseaudio article, especially the section on Pulseaudio from within a chroot.

Enabling sound in Firefox

Open a text editor and save the following in Template:Filename as root:

schroot -p firefox $1;export FIREFOX_DSP="aoss"

Make it executable:

sudo chmod +x /usr/bin/firefox32

Now you can make an alias for Firefox, if desired:

alias firefox="firefox32"

Add this to the end of file Template:Filename and source it to enable its usage. Or you can just change all your desktop environment's launchers to firefox32 if you still want 64-bit Firefox to be available.

Enabling 3D acceleration

In case you want to run any 32 bit application under your chroot with 3D acceleration (e.g. WINE, native 32 bit games) you simply need to install the corresponding libs as under your "native" arch.

For an ATI card using the radeon driver this could be:

pacman -S xf86-video-ati libgl ati-dri

For more informations on how to set up your graphic adapter refer to:




Your can easily check if you have 3D rendering within the 32 bit chroot by installing mesa and running the following command:

 glxinfo | grep renderer

If you have no 3D acceleration you'll get some output like this:

 [joe@arch64]$ OpenGL renderer string: Software Rasterizer

If 3D acceleration is enabled you'll get a message like this:

 [joe@arch64]$ OpenGL renderer string: Mesa DRI R600 (RV730 9490) 20090101 x86/MMX+/3DNow!+/SSE2 TCL DRI2

Script for wine

In order to compile wine, you need a 32-bit system installed. Compiling wine is needed for applying patches in order to get PulseAudio working. See also wine-hacks from AUR.

Add the following alias to Template:Filename:

alias wine='schroot -pqd "$(pwd)" -- wine'

The Template:Codeline switch makes schroot operate in quiet mode, so it works like "regular" wine does. Also note that If you still use dchroot instead of schroot, you should use switch Template:Codeline instead of Template:Codeline.