From ArchWiki
Jump to navigation Jump to search

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Arch32#)

Note: 32-bit chroot for a 64-bit Arch is described in Install_bundled_32-bit_system_in_Arch64 in great detail.

First we decide where to place the 32bit system. This variable will be used throughout this page for flexibilty. The given value is just what the author used. If you prefer some other location, this is the time to change it.


Now we have to create the directories so that pacman can function and affect changes inside our chroot.

mkdir -p $ARCH32_ROOT/var/{cache/pacman/pkg,lib/pacman}

Below is a helper script which I place in /usr/local/bin/pacman32. It will allow us to run pacman from our 64bit install and it will affect our chroot only. Make sure that if you are not using the default location, to change it here.


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

$PACMAN_EXEC --root $ARCH32_ROOT --cachedir $ARCH32_ROOT/var/cache/pacman/pkg --config $ARCH32_ROOT/pacman.conf "$@"

Now we can sync up our 32bit pacman with the repositories.

/usr/local/bin/pacman32 -Sy

And then we install the bare-minimum that we need to install other 32bit programs and libraries.

/usr/local/bin/pacman32 -S filesystem licenses bash sed coreutils gzip

We now setup some of the meaningful configuration files.

cd $ARCH32_ROOT/etc

ln -f /etc/passwd* 
ln -f /etc/shadow* 
ln -f /etc/group*
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
ln -f /etc/vimrc
cp /etc/mtab .


schroot -p -- "$@"

Alternative Setup (Testing)

This setup is being tested and so far seems to work well. It is based on the above comments and the more detailed description in Install_bundled_32-bit_system_in_Arch64.

Create Folder Structure

Create folder to store and sync 32-bit system (as root):

# mkdir /opt/arch32

Create pacman folder structure inside new location:

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

Pacman Configuration

Copy the pacman config files from 64-bit system and edit pacman sync files to work as 32-bit system. These two commands will copy and change /etc/pacman.conf and /etc/pacman.d/mirrorlist to be saved in /opt/arch32.

# sed -e 's/x86_64/i686/g' /etc/pacman.d/mirrorlist > /opt/arch32/mirrorlist
# sed -e 's@/etc/pacman.d/mirrorlist@/opt/arch32/mirrorlist@g' -e 's/Architecture = auto/Architecture = i686/g' /etc/pacman.conf > /opt/arch32/pacman.conf

N.B. Check that both files in /opt/arch32 point to i686 mirrors - 'Architecture = i686' in /etc/pacman.conf is correct.

Sync 32-bit System Using 64-bit Pacman Command

Use this pacman command to sync files to correct location in /opt/arch32 from 64-bit system:

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

Some of the repositories may not work when syncing, e.g. multilib.

Once pacman is synchronised, install minimum packages:

# pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -S filesystem licenses bash sed coreutils gzip pacman (nano make file gawk grep gcc)

Extra packages in brackets are useful for compiling packages in 32-bit system, e.g. from AUR

Create links in 32-bit system from useful conf files in 64-bit system (some are optional), first change to /opt/arch32/etc directory:

# cd /opt/arch32/etc

Run these commands, including '.' character (during the testing only those marked with required have been needed)

ln -f /etc/passwd* . 
ln -f /etc/shadow* . 
ln -f /etc/group* .
ln -f /etc/rc.conf . 
ln -f /etc/resolv.conf .    --> required
ln -f /etc/localtime . 
ln -f /etc/locale.gen .    --> required
ln -f /etc/profile.d/ profile.d
ln -f /etc/vimrc .
cp /etc/mtab .

Create Chroot Environment Scripts

Copy bash script below and save as arch32 in /etc/rc.d/


. /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 make script executable

# chmod +x /etc/rc.d/arch32

In the other descriptions, arch32 daemon was added to /etc/rc.conf. When this daemon is running from start-up, the 64-bit pacman commands to sync to the 32-bit system above don't seem to work properly. This bash script below, executed as user, to chroot into new 32-bit system gets round that problem. Useful for testing....


# Start chroot daemon
sudo /etc/rc.d/arch32 start

# Give users access to Xserver (install xorg-xhost if command not found)
xhost +                    

# Chroot into 32-bit system
sudo chroot /opt/arch32

# To leave chroot type 'exit' then environment is cleaned up..... 
xhost -
sudo /etc/rc.d/arch32 stop

N.B. The command:

# xhost + 

seems to work better than the suggested method:

# xhost +SI:localuser:username

Chroot Into 32-bit System

Run shell script as user (named in this instance) to chroot in 32-bit system. N.B. At this stage all commands are being run as root.

To distinguish between command prompts when running inside the 32-bit system, try altering the bash prompt to signify what is running,

e.g copy your user's .bashrc file into the root's home folder inside 32-bit system, /opt/arch32/root and comment out the usual bash prompt line:

PS1='[\u@\h \W]\$ '

and add:

PS1="\[\e[1;34m\][arch32][\u@\h \w]: "

This command will change the text colour to blue and put [arch32] before the normal information.

Set locale:

# locale-gen

Modify pacman config files inside 32-bit system: uncomment required mirrors in /etc/pacman.d/mirrorlist and as before, change 'Architecture' entry from 'auto' to 'i686' in /etc/pacman.conf

Add any additional repositories and sync:

# pacman -Sy

and install some software:

# pacman -S firefox

N.B. At this point there's no need to add any video drivers, but fonts are needed:

# pacman -S ttf-dejavu ttf-liberation

Run program:

# firefox

Exiting 32-bit system


# exit