Difference between revisions of "Install bundled 32-bit system in 64-bit system"

From ArchWiki
Jump to: navigation, search
m (typo)
(wikify some external links, use https for archlinux.org)
(38 intermediate revisions by 14 users not shown)
Line 1: Line 1:
[[Category:Arch64 (English)]]
+
[[Category:Arch64]]
{{i18n|Install bundled 32-bit system in Arch64}}
+
[[cs:32bit chroot]]
 +
[[fr:Install environnement 32 sur un systeme 64]]
 +
[[zh-CN:Install bundled 32-bit system in Arch64]]
 +
{{Article summary start}}
 +
{{Article summary text|
 +
This article presents one way of running 32-bit applications, which may be of use to those who do not wish to install the lib32-* libraries from the multilib repository and instead prefer to isolate 32bit applications. The approach involves creating a "chroot jail" to handle 32-bit apps.}}
 +
{{Article summary end}}
  
This article presents one way of running 32-bit applications, which may be of use to those who do not wish to install the lib32-* libraries from the multilib repository and instead prefer to isolate 32bit applications. The approach involves creating a "chroot jail" to handle 32-bit apps.
+
==Install the Base 32-bit System==
 +
1. Create the directory:
 +
{{bc|mkdir /opt/arch32}}
  
Before proceeding:
+
2. Generate temporary [[pacman]] configuration files for chroot:
* Note that this script's author is not an expert so there may be errors.
+
{{bc|sed -e 's/\$arch/i686/g' /etc/pacman.d/mirrorlist > /opt/arch32/mirrorlist
* 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.
+
sed -e 's@/etc/pacman.d/mirrorlist@/opt/arch32/mirrorlist@g' /etc/pacman.conf > /opt/arch32/pacman.conf}}
* If you have a custom kernel configuration, you need to make sure that this option is set: {{Codeline|<nowiki>CONFIG_IA32_EMULATION=y</nowiki>}}. 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.
+
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 ({{ic|/opt/arch32}} is used here). Remember to delete/comment the multilib repo, if you have enable it, in the {{ic|/opt/arch32/pacman.conf}} file
  
==Install the base 32-bit system==
+
The  {{ic|--root}} switch in the pacman command below will create {{ic|/var/log/pacman.log}} and {{ic|/var/lib/pacman/db.lck}} inside {{ic|/opt/arch32}}. The pacman log will be {{ic|/opt/arch32/var/log/pacman.log}} and will ''not'' interfere with the native 64-bit installation. There is no need for a {{ic|LogFile}} directive in {{ic|/etc/pacman.conf}} or a {{ic|--logfile}} switch.
1. Create the repository:
+
mkdir /opt/arch32
+
  
2. Generate temporary [[pacman]] configuration files for the new repository:
+
The {{ic|--cachedir}} switch is for the package to be cached in {{ic|/opt/arch32/var/cache/pacman/pkg}} instead of {{ic|/var/cache/pacman/pkg}}.
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 ({{Filename|/opt/arch32}} 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 {{Codeline|--root}} switch in the pacman command below, files {{Filename|/var/log/pacman.log}} and {{Filename|/var/lib/pacman/db.lck}} will be created inside {{Filename|/opt/arch32}}. The pacman log will be {{Filename|/opt/arch32/var/log/pacman.log}} and will ''not'' interfere with your 64-bit installation. There is no need for a {{Codeline|LogFile}} directive in {{Filename|/etc/pacman.conf}} or a {{Codeline|--logfile}} switch unless you want the log file to be elsewhere.
+
Use the {{ic|--config}} switch to tell pacman to use the configuration file generated above, rather than {{ic|/etc/pacman.conf}}.
 
+
The {{Codeline|--cachedir}} switch is for the package to be cached in the {{Filename|/opt/arch32/var/cache/pacman/pkg}} directory instead of {{Filename|/var/cache/pacman/pkg}}.
+
 
+
Use the {{Codeline|--config}} switch to tell pacman to use the configuration file ganerated above, rather than {{Filename|/etc/pacman.conf}}.
+
  
 
3. Create the directory, just to be sure:
 
3. Create the directory, just to be sure:
Line 33: Line 32:
 
  Architecture=i686
 
  Architecture=i686
  
3c. If you used the Arch installer, you will have a line at the top of /etc/pacman.d/mirrorlist like this:
+
3c. Users following the Arch installer method will have a line at the top of {{ic|/etc/pacman.d/mirrorlist}} similar to:
  # Mirror used during installation
+
{{bc|1=# Mirror used during installation
  Server = http://mirror.rit.edu/archlinux/$repo/os/x86_64
+
Server = http://mirror.rit.edu/archlinux/$repo/os/x86_64}}
  
 
The 'sed' command above searches for instances of '$arch' and replaces them with 'i686'. Unfortunately, since this installation mirror is explicitly set as x86_64, it is not replaced and will cause issues. Either comment it out or change it like so:
 
The 'sed' command above searches for instances of '$arch' and replaces them with 'i686'. Unfortunately, since this installation mirror is explicitly set as x86_64, it is not replaced and will cause issues. Either comment it out or change it like so:
  Server = http://mirror.rit.edu/archlinux/$repo/os/i686
+
{{bc|1=Server = http://mirror.rit.edu/archlinux/$repo/os/i686}}
  
4. Now proceed to sync pacman:
+
4. Sync pacman:
 
  pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -Sy
 
  pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -Sy
  
5. Install the base packages:
+
5. Install the base and optionally base-devel groups:
 
  pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -S base base-devel
 
  pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -S base base-devel
 +
{{Note|For minimal arch32 chroot installation following packages are sufficient: bash, coreutils, filesystem, grep, gzip, licenses, sed, pacman and file.}}
  
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.
+
Optionally remove the temporary pacman configuration files.
 +
 
 
  rm /opt/arch32/{mirrorlist,pacman.conf}
 
  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.  '''You will also need to edit your /opt/arch32/etc/pacman.conf and change that Architecture from auto back to i686.'''
 
  
===Alternative lightweight install===
+
6. To use the newly installed pacman, uncomment some mirrors in {{ic|/opt/arch32/etc/pacman.d/mirrorlist}} and make any other desired changes to the new pacman installation.
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:
+
7. Edit your /opt/arch32/etc/pacman.conf and change that Architecture from auto back to i686.
mkdir /opt/arch32
+
  
And then the pacman configuration files. However, unlike in the previous method, these files should not be removed:
+
== Create an Arch32 Daemon Script and Systemd Service ==
sed -e 's/\$arch/i686/g' /etc/pacman.d/mirrorlist > /opt/arch32/mirrorlist
+
{{hc|/etc/systemd/system/arch32.service|<nowiki>
sed -e 's@/etc/pacman.d/mirrorlist@/opt/arch32/mirrorlist@g' /etc/pacman.conf > /opt/arch32/pacman.conf
+
[Unit]
 +
Description=32-bit chroot
  
Create necessary directories for the new system. Note that {{Filename|/opt/arch32/var/lib/dbus}} 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.
+
[Service]
mkdir -p /opt/arch32/var/{cache/pacman/pkg,lib/pacman,lib/dbus}
+
Type=oneshot
 +
RemainAfterExit=yes
 +
ExecStart=/usr/local/bin/arch32 start
 +
ExecStop=/usr/local/bin/arch32 stop
  
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:
+
[Install]
alias pacman32="pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf"
+
WantedBy=multi-user.target
 +
</nowiki>}}
  
Edit 'Architecture' for pacman >= 3.4
+
{{hc|/usr/local/bin/arch32|<nowiki>
# In /opt/arch32/pacman.conf
+
#!/bin/bash
# Architecture=auto
+
Architecture=i686
+
  
Sync pacman32:
+
# Add '/var/run /var/lib/dbus' to the list to enable pulseaudio.
pacman32 -Sy
+
dirs=(/dev /dev/pts /dev/shm /tmp /home)
  
Install basic packages for 32-bit subsystem. These are the minimal packages that allow you to chroot to the subsystem and run {{Codeline|locale-gen}} script for <tt>i18n</tt>.
 
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 {{Filename|/etc/rc.d/}} called {{Filename|arch32}}:
 
 
<pre>#!/bin/bash
 
 
. /etc/rc.conf
 
. /etc/rc.d/functions
 
 
dirs=(/dev /dev/pts /dev/shm /tmp /home)
 
 
case $1 in
 
case $1 in
 
     start)
 
     start)
        stat_busy "Starting Arch32 chroot"
 
 
         for d in "${dirs[@]}"; do
 
         for d in "${dirs[@]}"; do
        mount -o bind $d /opt/arch32/$d
+
            mount -o bind $d /opt/arch32$d
 
         done
 
         done
        mount -t proc none /opt/arch32/proc
 
        mount -t sysfs none /opt/arch32/sys
 
        add_daemon arch32
 
        stat_done
 
 
         ;;
 
         ;;
 
     stop)
 
     stop)
        stat_busy "Stopping Arch32 chroot"
 
 
         for (( i = ${#dirs[@]} - 1; i >= 0; i-- )); do
 
         for (( i = ${#dirs[@]} - 1; i >= 0; i-- )); do
        umount "/opt/arch32${dirs[i]}"
+
            umount "/opt/arch32${dirs[i]}"
 
         done
 
         done
 
         umount /opt/arch32/{proc,sys}
 
         umount /opt/arch32/{proc,sys}
        rm_daemon arch32
 
        stat_done
 
        ;;
 
    restart)
 
        $0 stop
 
        sleep 1
 
        $0 start
 
 
         ;;
 
         ;;
 
     *)
 
     *)
         echo "usage: $0 {start|stop|restart}"
+
         echo "usage: $0 (start|stop)"
esac
+
        exit 1
exit 0</pre>
+
esac</nowiki>}}
  
Then allow execution of the script:
+
Be sure to make the init script executable:
  chmod +x /etc/rc.d/arch32
+
  # chmod +x /usr/local/bin/arch32
  
And add it to {{Filename|/etc/rc.conf}}:
+
Enable the service as any other systemd service.
DAEMONS=(syslog-ng network netfs '''arch32''' crond)
+
  
 
==Configure the new system==
 
==Configure the new system==
First, copy important configuration files:
+
===Configuration files===
 +
Key configuration files should be copied over:
 +
 
 
  cd /opt/arch32/etc
 
  cd /opt/arch32/etc
 
   
 
   
  ln -f /etc/passwd* .
+
  cp /etc/passwd* .
  ln -f /etc/shadow* .
+
  cp /etc/shadow* .
  ln -f /etc/group* .
+
  cp /etc/group* .
  ln -f /etc/sudoers .  # note: you'll need to install sudo before creating this entry, or sudo will refuse to install
+
  cp /etc/sudoers .  # note: you'll need to install sudo before creating this entry, or sudo will refuse to install
 
   
 
   
  ln -f /etc/rc.conf .
+
  cp /etc/rc.conf .
  ln -f /etc/resolv.conf .
+
  cp /etc/resolv.conf .
 
   
 
   
  ln -f /etc/localtime .
+
  cp /etc/localtime .
  ln -f /etc/locale.gen .
+
  cp /etc/locale.gen .
  ln -f /etc/profile.d/locale.sh profile.d
+
  cp /etc/profile.d/locale.sh profile.d
 
   
 
   
 
  cp /etc/vimrc .
 
  cp /etc/vimrc .
 
  cp /etc/mtab .
 
  cp /etc/mtab .
 +
cp /etc/sudoers .
 
Be sure to include the "." character.
 
Be sure to include the "." character.
  
Now chroot into your new system:
+
=== Configure the chroot ===
 +
Chroot into the new system:
 
  /etc/rc.d/arch32 start
 
  /etc/rc.d/arch32 start
 
  xhost +SI:localuser:usernametogiveaccesstogoeshere  
 
  xhost +SI:localuser:usernametogiveaccesstogoeshere  
 
  chroot /opt/arch32
 
  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 {{Filename|~/.bashrc}}.  In fact, the default Debian .bashrc prompt string contains appropriate logic to report whether the working directory is within a chroot.
+
It is recommended to 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 {{ic|~/.bashrc}}.  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 {{Filename|/etc/pacman.conf}} 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.
+
Before continuing, keep in mind that the file {{ic|/etc/pacman.conf}} from the 32-bit environment is the default one.  Make sure to uncomment some mirrors in {{ic|/etc/pacman.d/mirrorlist}}.
  
 
Fix possible locale issues:
 
Fix possible locale issues:
 
  /usr/sbin/locale-gen
 
  /usr/sbin/locale-gen
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:
+
Install the needed packages including apps, fonts, etc. for example:
 +
 
 
  pacman -S acroread opera
 
  pacman -S acroread opera
 
  pacman -S firefox
 
  pacman -S firefox
Line 168: Line 141:
 
  pacman -S mplayer-plugin
 
  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:
+
Regain space by removing some unnecessary packages.
  pacman -Rd mkinitcpio
+
 
  pacman -R kernel26 \
+
{{Warning| This cleanup is for the '''32-bit''' root environment and must then be done inside it NOT the native 64-bit environment!}}
grub \
+
 
dhcpcd \
+
The following shows recommended packages for removal:
rp-pppoe \
+
 
ppp \
+
  pacman -Rd linux mkinitcpio
xfsprogs \
+
  pacman -R dhcpcd ppp xfsprogs reiserfsprogs jfsutils syslog-ng logrotate lvm2 wpa_supplicant pcmciautils
reiserfsprogs \
+
jfsutils \
+
hdparm \
+
hwdetect \
+
syslog-ng \
+
logrotate \
+
lvm2 \
+
dcron \
+
wpa_supplicant \
+
pcmciautils
+
  
 
Also consider regularly clearing out pacman's cache:
 
Also consider regularly clearing out pacman's cache:
  pacman -Sc
+
  pacman -Scc
  
==Executing 32-bit applications from a 64-bit environment==
+
== Install and Configure Schroot ==
  
Install "schroot" to your '''64-bit''' installation:
+
Install "schroot" to the native '''64-bit''' installation:
 
  pacman -S schroot
 
  pacman -S schroot
  
Schroot is already configured for Arch32 chroot, so you should just check {{Filename|/etc/schroot/schroot.conf}}, section ''[Arch32]'', to check if it matches your configuration. You will also want to edit {{Filename|/etc/schroot/mount-arch32}} to match the mounts you created within {{Filename|/etc/rc.d/arch32}}, because applications run through schroot will not be able to see mounts not listed in {{Filename|/etc/schroot/mount-arch32}}.
+
Edit {{ic|/etc/schroot/schroot.conf}}, and create an ''[Arch32]'' section.
  
Finally, to use your 32-bit applicationss:
+
[Arch32]
  schroot -p -- opera
+
type=directory
It will launch Opera from the 32-bit environment.
+
profile=arch32
 +
description=Arch32
 +
directory=/opt/arch32
 +
users=user1,user2,user3
 +
  groups=users
 +
root-groups=root
 +
personality=linux32
 +
aliases=32,default
  
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 {{Filename|firefox.cpp}} and compile by pressing F9:
+
Optionally edit {{ic|/etc/schroot/arch32/mount}} to match the mounts created within {{ic|/etc/rc.d/arch32}}.
#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];
+
    temp+=temp2;
+
    system(temp.c_str());
+
    return 0;
+
}
+
Now replace firefox binary file in {{Filename|/usr/lib/firefox-3.0.1}} with the compiled file. Change "''3.0.1''" to the appropriate version.
+
  
===Java in a chroot===
+
== Using Schroot to run a 32-bit application ==
See [[Java]] for installation instructions.
+
  
After installing, adjust the path to get Java working:
+
The general syntax for calling an application ''inside'' the chroot is:
  export PATH="/opt/java/bin/:$PATH"
+
 
 +
  schroot -p -- htop
 +
 
 +
In this example, htop is called from within the 32-bit environment.
  
 
==Troubleshooting==
 
==Troubleshooting==
  
 
===Compilation and installing===
 
===Compilation and installing===
Ensure the desired options are set in the local {{Filename|/etc/makepkg.conf}}.
+
Ensure the desired options are set in the local {{ic|/etc/makepkg.conf}}.
  
Some packages may require a {{Codeline|--host}} flag be added to the ./configure script in the PKBUILD:
+
Some packages may require a {{ic|--host}} flag be added to the ./configure script in the PKBUILD:
 
  ./configure --host="i686-pc-linux" ...
 
  ./configure --host="i686-pc-linux" ...
This is the case when the build makes use of values (for example, the output of the {{Codeline|uname}} command) inherited from your base system.
+
This is the case when the build makes use of values (for example, the output of the {{ic|uname}} 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:
 
You may need to give users write access to your chroot's /dev/null to stop some scripts from failing:
Line 260: Line 217:
  
 
==Tips and tricks==
 
==Tips and tricks==
 +
===Java in a chroot===
 +
See [[Java]] for installation instructions.
 +
 +
After installing, adjust the path to get Java working:
 +
export PATH="/opt/java/bin/:$PATH"
 
===arch32-light===
 
===arch32-light===
Xyne has created a package that installs a minimalist 32-bit chroot as described above. More information can be found [http://bbs.archlinux.org/viewtopic.php?id=97629 on the forum] and [http://xyne.archlinux.ca/projects/arch32-light on the project page].
+
Xyne has created a package that installs a minimalist 32-bit chroot as described above. More information can be found [https://bbs.archlinux.org/viewtopic.php?id=97629 on the forum] and [http://xyne.archlinux.ca/projects/arch32-light on the project page].
  
 
===Allowing 32-bit applications access to 64-bit Pulseaudio===
 
===Allowing 32-bit applications access to 64-bit Pulseaudio===
  
Add these lines in {{Filename|/etc/rc.d/arch32}}, above {{Codeline|add_daemon arch32}}:
+
Add these lines in {{ic|/etc/rc.d/arch32}}, above {{ic|add_daemon arch32}}:
 
  mount --bind /var/run /opt/arch32/var/run
 
  mount --bind /var/run /opt/arch32/var/run
 
  mount --bind /var/lib/dbus /opt/arch32/var/lib/dbus
 
  mount --bind /var/lib/dbus /opt/arch32/var/lib/dbus
  
And above {{Codeline|rm_daemon arch32}}:
+
And above {{ic|rm_daemon arch32}}:
 
  umount /opt/arch32/var/run
 
  umount /opt/arch32/var/run
 
  umount /opt/arch32/var/lib/dbus
 
  umount /opt/arch32/var/lib/dbus
  
More information is available at the [[Pulseaudio]] article, especially the section on [http://wiki.archlinux.org/index.php/PulseAudio#Pulseaudio_from_within_a_chroot_.28ex._32-bit_chroot_in_64-bit_install.29 Pulseaudio from within a chroot].
+
More information is available at the [[Pulseaudio]] article, especially the section on [[PulseAudio#Pulseaudio_from_within_a_chroot_.28ex._32-bit_chroot_in_64-bit_install.29|Pulseaudio from within a chroot]].
  
 
===Enabling sound in Firefox===
 
===Enabling sound in Firefox===
Open a text editor and save the following in {{Filename|/usr/bin/firefox32}} as root:
+
Open a text editor and save the following in {{ic|/usr/bin/firefox32}} as root:
 
  #!/bin/sh
 
  #!/bin/sh
 
  schroot -p firefox $1;export FIREFOX_DSP="aoss"
 
  schroot -p firefox $1;export FIREFOX_DSP="aoss"
Line 286: Line 248:
 
  alias firefox="firefox32"
 
  alias firefox="firefox32"
  
Add this to the end of file {{Filename|~/.bashrc}} 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.
+
Add this to the end of file {{ic|~/.bashrc}} 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===
 
===Enabling 3D acceleration===
Line 302: Line 264:
 
[[NVIDIA]]
 
[[NVIDIA]]
  
Your can easily check if you have 3D rendering within the 32 bit chroot by installing mesa and running the following command:
+
Your can easily check if you have 3D rendering within the 32 bit chroot by installing mesa-demos and running the following command:
 
   glxinfo | grep renderer
 
   glxinfo | grep renderer
  
Line 312: Line 274:
  
 
===Script for wine===
 
===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 [http://art.ified.ca/?page_id=40 PulseAudio] working. See also [http://aur.archlinux.org/packages.php?ID=19675 wine-hacks] from AUR.
+
In order to compile wine, you need a 32-bit system installed. Compiling wine is needed for applying patches in order to get [http://art.ified.ca/?page_id=40 PulseAudio] working. See also [https://aur.archlinux.org/packages.php?ID=19675 wine-hacks] from AUR.
  
Add the following alias to {{Filename|~/.bashrc}}:
+
Add the following alias to {{ic|~/.bashrc}}:
 
  alias wine='schroot -pqd "$(pwd)" -- wine'
 
  alias wine='schroot -pqd "$(pwd)" -- wine'
The {{Codeline|-q}} 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 {{Codeline|-d}} instead of {{Codeline|-s}}.
+
The {{ic|-q}} 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 {{ic|-d}} instead of {{ic|-s}}.

Revision as of 15:54, 4 December 2012

Template:Article summary start Template:Article summary text Template:Article summary end

Install the Base 32-bit System

1. Create the directory:

mkdir /opt/arch32

2. Generate temporary pacman configuration files for chroot:

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 (/opt/arch32 is used here). Remember to delete/comment the multilib repo, if you have enable it, in the /opt/arch32/pacman.conf file

The --root switch in the pacman command below will create /var/log/pacman.log and /var/lib/pacman/db.lck inside /opt/arch32. The pacman log will be /opt/arch32/var/log/pacman.log and will not interfere with the native 64-bit installation. There is no need for a LogFile directive in /etc/pacman.conf or a --logfile switch.

The --cachedir switch is for the package to be cached in /opt/arch32/var/cache/pacman/pkg instead of /var/cache/pacman/pkg.

Use the --config switch to tell pacman to use the configuration file generated above, rather than /etc/pacman.conf.

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
Architecture=i686

3c. Users following the Arch installer method will have a line at the top of /etc/pacman.d/mirrorlist similar to:

# Mirror used during installation
Server = http://mirror.rit.edu/archlinux/$repo/os/x86_64

The 'sed' command above searches for instances of '$arch' and replaces them with 'i686'. Unfortunately, since this installation mirror is explicitly set as x86_64, it is not replaced and will cause issues. Either comment it out or change it like so:

Server = http://mirror.rit.edu/archlinux/$repo/os/i686

4. Sync pacman:

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

5. Install the base and optionally base-devel groups:

pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -S base base-devel
Note: For minimal arch32 chroot installation following packages are sufficient: bash, coreutils, filesystem, grep, gzip, licenses, sed, pacman and file.


Optionally remove the temporary pacman configuration files.

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

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

7. Edit your /opt/arch32/etc/pacman.conf and change that Architecture from auto back to i686.

Create an Arch32 Daemon Script and Systemd Service

/etc/systemd/system/arch32.service
[Unit]
Description=32-bit chroot

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/arch32 start
ExecStop=/usr/local/bin/arch32 stop

[Install]
WantedBy=multi-user.target
/usr/local/bin/arch32
#!/bin/bash

# Add '/var/run /var/lib/dbus' to the list to enable pulseaudio.
dirs=(/dev /dev/pts /dev/shm /tmp /home)

case $1 in
    start)
        for d in "${dirs[@]}"; do
            mount -o bind $d /opt/arch32$d
        done
        ;;
    stop)
        for (( i = ${#dirs[@]} - 1; i >= 0; i-- )); do
            umount "/opt/arch32${dirs[i]}"
        done
        umount /opt/arch32/{proc,sys}
        ;;
    *)
        echo "usage: $0 (start|stop)"
        exit 1
esac

Be sure to make the init script executable:

# chmod +x /usr/local/bin/arch32

Enable the service as any other systemd service.

Configure the new system

Configuration files

Key configuration files should be copied over:

cd /opt/arch32/etc

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

cp /etc/rc.conf .
cp /etc/resolv.conf .

cp /etc/localtime .
cp /etc/locale.gen .
cp /etc/profile.d/locale.sh profile.d

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

Be sure to include the "." character.

Configure the chroot

Chroot into the new system:

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

It is recommended to 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 ~/.bashrc. 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 /etc/pacman.conf from the 32-bit environment is the default one. Make sure to uncomment some mirrors in /etc/pacman.d/mirrorlist.

Fix possible locale issues:

/usr/sbin/locale-gen

Install the needed packages including apps, fonts, etc. for example:

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

Regain space by removing some unnecessary packages.

Warning: This cleanup is for the 32-bit root environment and must then be done inside it NOT the native 64-bit environment!

The following shows recommended packages for removal:

pacman -Rd linux mkinitcpio
pacman -R dhcpcd ppp xfsprogs reiserfsprogs jfsutils syslog-ng logrotate lvm2 wpa_supplicant pcmciautils

Also consider regularly clearing out pacman's cache:

pacman -Scc

Install and Configure Schroot

Install "schroot" to the native 64-bit installation:

pacman -S schroot

Edit /etc/schroot/schroot.conf, and create an [Arch32] section.

[Arch32]
type=directory
profile=arch32
description=Arch32
directory=/opt/arch32
users=user1,user2,user3
groups=users
root-groups=root
personality=linux32
aliases=32,default

Optionally edit /etc/schroot/arch32/mount to match the mounts created within /etc/rc.d/arch32.

Using Schroot to run a 32-bit application

The general syntax for calling an application inside the chroot is:

schroot -p -- htop

In this example, htop is called from within the 32-bit environment.

Troubleshooting

Compilation and installing

Ensure the desired options are set in the local /etc/makepkg.conf.

Some packages may require a --host 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 uname 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

Java in a chroot

See Java for installation instructions.

After installing, adjust the path to get Java working:

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

arch32-light

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 /etc/rc.d/arch32, above add_daemon arch32:

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

And above rm_daemon arch32:

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 /usr/bin/firefox32 as root:

#!/bin/sh
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 ~/.bashrc 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:

ATI

Intel

NVIDIA

Your can easily check if you have 3D rendering within the 32 bit chroot by installing mesa-demos 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 ~/.bashrc:

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

The -q 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 -d instead of -s.