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

From ArchWiki
Jump to: navigation, search
(lt;dr version)
(improve install link as recommended in Help:Style#Package management instructions)
 
(69 intermediate revisions by 20 users not shown)
Line 1: Line 1:
[[Category:Arch64]]
+
[[Category:Getting and installing Arch]]
[[cs:32bit chroot]]
+
[[cs:Install bundled 32-bit system in 64-bit system]]
 
[[fr:Install environnement 32 sur un systeme 64]]
 
[[fr:Install environnement 32 sur un systeme 64]]
[[zh-CN:Install bundled 32-bit system in Arch64]]
+
[[ja:64ビット環境に32ビット環境をインストール]]
{{Article summary start}}
+
[[zh-cn:Install bundled 32-bit system in 64-bit system]]
{{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.
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}}
+
  
== Make the i686 Chroot ==
+
{{Tip|1=Xyne has created a package that installs a minimalist 32-bit chroot as described below. See [https://bbs.archlinux.org/viewtopic.php?id=97629] and [http://xyne.archlinux.ca/projects/arch32-light] for details.}}
=== tl;dr version ===
+
For those wanting a single copy/paste:
+
export LOCATION=/opt/arch32 # more flexibility here if users which an alternative location for the chroot
+
mkdir $LOCATION
+
sed -e 's/\$arch/i686/g' /etc/pacman.d/mirrorlist > $LOCATION/mirrorlist
+
sed -e 's@/etc/pacman.d/mirrorlist@$LOCATION/mirrorlist@g' -e '/Architecture/ s,auto,i686,'  /etc/pacman.conf > $LOCATION/pacman.conf
+
mkdir -p $LOCATION/var/{cache/pacman/pkg,lib/pacman}
+
pacman --root $LOCATION --cachedir $LOCATION/var/cache/pacman/pkg --config $LOCATION/pacman.conf -Sy
+
pacman --root $LOCATION --cachedir $LOCATION/var/cache/pacman/pkg --config $LOCATION/pacman.conf -S base base-devel
+
mv $LOCATION/mirrorlist $LOCATION/etc/pacman.d
+
cd $LOCATION/etc
+
cp /etc/passwd* .
+
cp /etc/shadow* .
+
cp /etc/group* .
+
cp /etc/sudoers .
+
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/inputrc .
+
  
===Install the Base 32-bit System===
+
== Installation ==
  
 
1. Create the directory:
 
1. Create the directory:
  mkdir /opt/arch32
+
 
 +
  # mkdir /opt/arch32
  
 
2. Generate temporary [[pacman]] configuration files for chroot:
 
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' -e '/Architecture/ s,auto,i686,'  /etc/pacman.conf > /opt/arch32/pacman.conf
+
  # sed -e 's/\$arch/i686/g' /etc/pacman.d/mirrorlist > /opt/arch32/mirrorlist
 +
  # sed -e 's@/etc/pacman.d/mirrorlist@/opt/arch32/mirrorlist@g' -e '/Architecture/ s,auto,i686,'  /etc/pacman.conf > /opt/arch32/pacman.conf
  
 
*These files would conflict with the normal pacman files, which will be installed in the later steps.
 
*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).
 
*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
+
*Remember to delete/comment the multilib repo, if you have enabled it, in the {{ic|/opt/arch32/pacman.conf}} file
  
 
3. Create the directory:
 
3. Create the directory:
  mkdir -p /opt/arch32/var/{cache/pacman/pkg,lib/pacman}
+
 
 +
  # mkdir -p /opt/arch32/var/{cache/pacman/pkg,lib/pacman}
  
 
4. 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 and optionally base-devel groups:
 
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
  
 
Optionally add your favorite text editor and distcc if you plan to compile within the chroot with other machines:
 
Optionally add your favorite text editor and distcc if you plan to compile within the chroot with other machines:
  pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -S base base-devel sudo vim distcc
+
 
 +
  # pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -S base base-devel sudo vim distcc
  
 
Optionally move the pacman mirror list into place:
 
Optionally move the pacman mirror list into place:
mv /opt/arch32/mirrorlist /opt/arch32/etc/pacman.d
 
  
===Configuration files===
+
# mv /opt/arch32/mirrorlist /opt/arch32/etc/pacman.d
Key configuration files should be copied over:
+
  
cd /opt/arch32/etc
+
=== Settings ===
+
cp /etc/passwd* .
+
cp /etc/shadow* .
+
cp /etc/group* .
+
cp /etc/sudoers .
+
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/inputrc .
+
  
Be sure to include the "." character!
+
Key configuration files should be copied over:
 +
 
 +
# for i in passwd* shadow* group* sudoers resolv.conf localtime locale.gen vimrc mtab inputrc profile.d/locale.sh; do cp -p /etc/"$i" /opt/arch32/etc/; done
  
 
Remember to define the correct the number of MAKEFLAGS and other vars in {{ic|/opt/arch32/etc/makepkg.conf}} before attempting to build.
 
Remember to define the correct the number of MAKEFLAGS and other vars in {{ic|/opt/arch32/etc/makepkg.conf}} before attempting to build.
  
== Create an Arch32 Daemon Script and Systemd Service ==
+
=== Daemon and systemd service ===
 
{{hc|/etc/systemd/system/arch32.service|<nowiki>
 
{{hc|/etc/systemd/system/arch32.service|<nowiki>
 
[Unit]
 
[Unit]
Line 98: Line 68:
 
{{hc|/usr/local/bin/arch32|<nowiki>
 
{{hc|/usr/local/bin/arch32|<nowiki>
 
#!/bin/bash
 
#!/bin/bash
 +
 +
## User variables.
 +
MOUNTPOINT=/opt/arch32
 +
 +
## Set MANAGEPARTITION to any value if /opt/arch32 resides on a separate
 +
## partition and not mounted by /etc/fstab or some other means.
 +
## If /opt/arch32 is part of your rootfs, leave this empty.
 +
MANAGEPARTITION=
 +
 +
## Leave USEDISTCC empty unless you wish to use distccd from within the chroot.
 +
USEDISTCC=
 +
DISTCC_SUBNET='10.9.8.0/24'
 +
 +
## PIDFILE shouldn't need to ba changed from this default.
 +
PIDFILE=/run/arch32
  
 
start_distccd() {
 
start_distccd() {
[[ ! -L /opt/arch32/usr/bin/distccd-chroot ]] && ln -s /usr/bin/distccd /opt/arch32/usr/bin/distccd-chroot  
+
[[ ! -L "$MOUNTPOINT"/usr/bin/distccd-chroot ]] &&
DISTCC_ARGS="--user nobody --allow 192.168.0.0/24 --port 3692 --log-level warning --log-file /tmp/distccd-i686.log"
+
ln -s /usr/bin/distccd "$MOUNTPOINT"/usr/bin/distccd-chroot  
+
DISTCC_ARGS="--user nobody --allow $DISTCC_SUBNET --port 3692 --log-level warning --log-file /tmp/distccd-i686.log"
if [[ -z "$(pgrep distccd-chroot)" ]]; then
+
 
linux32 chroot /opt/arch32 /bin/bash -c "/usr/bin/distccd-chroot --daemon ${DISTCC_ARGS}"
+
[[ -z "$(pgrep distccd-chroot)" ]] &&
echo "Startup OK!"
+
linux32 chroot "$MOUNTPOINT" /bin/bash -c "/usr/bin/distccd-chroot --daemon $DISTCC_ARGS"
else
+
echo "/usr/bin/distccd-chroot seems to be running so doing nothing!"
+
fi
+
 
}
 
}
  
 
stop_distccd() {
 
stop_distccd() {
if [[ -n "$(pgrep distccd-chroot)" ]]; then
+
[[ -n "$(pgrep distccd-chroot)" ]] &&
linux32 chroot /opt/arch32 /bin/bash -c "pkill -SIGTERM distccd-chroot"
+
linux32 chroot "$MOUNTPOINT" /bin/bash -c "pkill -SIGTERM distccd-chroot"
echo "Shutdown OK!"
+
else
+
echo "/usr/bin/distccd-chroot does NOT seems to be running so doing nothing!"
+
fi
+
 
}
 
}
  
 
case $1 in
 
case $1 in
 
start)
 
start)
                # if you have the main chroot on another partition
+
[[ -f "$PIDFILE" ]] && exit 1
                # create the .arch32 file as a simple check for mount status
+
                # edit to fit your system and take note of the corresponding unmount option in the stop function
+
# [[ ! -f /opt/arch32/.arch32 ]] && mount LABEL="arch32" /opt/arch32
+
  
dirs=(/tmp /dev /dev/pts /scratch /home)
+
if [[ -n "$MANAGEPARTITION" ]]; then
 +
mountpoint -q $MOUNTPOINT || mount LABEL="arch32" $MOUNTPOINT
 +
fi
 +
 
 +
dirs=(/tmp /dev /dev/pts /home)
 
for d in "${dirs[@]}"; do
 
for d in "${dirs[@]}"; do
mount -o bind $d /opt/arch32$d
+
mount -o bind $d "$MOUNTPOINT"$d
 
done
 
done
mount -t proc none /opt/arch32/proc
+
 
mount -t sysfs none /opt/arch32/sys
+
mount -t proc none "$MOUNTPOINT/proc"
touch /run/arch32
+
mount -t sysfs none "$MOUNTPOINT/sys"
                # if you use distccd from within the chroot uncomment this and the corresponding line in the stop function
+
touch "$PIDFILE"
# start_distccd
+
[[ -n "$USEDISTCC" ]] && start_distccd
 
;;
 
;;
 +
 
stop)
 
stop)
dirs=(/home /scratch /dev/pts /tmp)
+
[[ ! -f "$PIDFILE" ]] && exit 1
                # if you use distccd from within the chroot uncomment this
+
[[ -n "$USEDISTCC" ]] && stop_distccd
# stop_distccd
+
 
umount /opt/arch32/{sys,proc}
+
if [[ -n "$MANAGEPARTITION" ]]; then
for d in "${dirs[@]}"; do
+
umount -R -A -l "$MOUNTPOINT"
umount "/opt/arch32$d"
+
else
done
+
dirs=(/home /dev/pts /dev /tmp)
sleep 5s
+
[[ -n "$USEDISTCC" ]] && stop_distccd
umount /opt/arch32/dev # needs to come out of the for loop
+
umount "$MOUNTPOINT"/{sys,proc}
                # if using a separate partition for arch32
+
for d in "${dirs[@]}"; do
# umount /opt/arch32
+
umount -l "$MOUNTPOINT$d"
rm -f /run/arch32
+
done
 +
fi
 +
 +
rm -f "$PIDFILE"
 
;;
 
;;
 
*)
 
*)
 
echo "usage: $0 (start|stop)"
 
echo "usage: $0 (start|stop)"
 
exit 1
 
exit 1
esac</nowiki>}}
+
esac
 +
</nowiki>}}
  
 
Be sure to make the init script executable:
 
Be sure to make the init script executable:
 
  # chmod +x /usr/local/bin/arch32
 
  # chmod +x /usr/local/bin/arch32
  
Enable the service as any other systemd service.
+
[[Start]] and optionally [[enable]] {{ic|arch32.service}}.
 +
 
 +
== Configuration ==
  
==Configure the new system==
 
=== Configure the chroot ===
 
 
Chroot into the new system:
 
Chroot into the new system:
  /etc/rc.d/arch32 start
+
 
  xhost +SI:localuser:usernametogiveaccesstogoeshere
+
  # /usr/local/bin/arch32 start
  chroot /opt/arch32
+
  $ xhost +SI:localuser:username_to_give_access_to
 +
  # 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 {{ic|~/.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.
  
 
=== First-time Setup ===
 
=== First-time Setup ===
Fix possible locale issues:
 
/usr/sbin/locale-gen
 
  
Initialize pacman:
+
Fix possible locale problems:
sed -i 's/CheckSpace/#CheckSpace/' /etc/pacman.conf
+
pacman-key --init
+
pacman-key --populate archlinux
+
  
=== Install Needed Packages ===
+
# /usr/bin/locale-gen
Install the needed packages including apps, fonts, etc. for example:
+
  
pacman -S firefox
+
Initialize pacman:
pacman -S flashplugin
+
  
=== Regain Space (Optional) ===
+
# sed -i 's/CheckSpace/#CheckSpace/' /etc/pacman.conf
{{Warning| This cleanup is for the '''32-bit''' root environment and must then be done inside it NOT the native 64-bit environment!}}
+
# pacman-key --init && pacman-key --populate archlinux
  
The following shows recommended packages for removal:
+
== Schroot ==
  
pacman -Rd linux mkinitcpio dhcpcd ppp xfsprogs reiserfsprogs jfsutils logrotate lvm2 pcmciautils netcfg heirloom-mailx iputils iproute2 man-pages mdadm inetutils man-db cronie vi
+
[[Install]] {{Pkg|schroot}} to the native '''64-bit''' installation:
 
+
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 {{ic|/etc/schroot/schroot.conf}}, and create an ''[Arch32]'' section.
 
Edit {{ic|/etc/schroot/schroot.conf}}, and create an ''[Arch32]'' section.
Line 213: Line 183:
 
  aliases=32,default
 
  aliases=32,default
  
Optionally edit {{ic|/etc/schroot/arch32/mount}} to match the mounts created within {{ic|/etc/rc.d/arch32}}.
+
Optionally edit {{ic|/etc/schroot/arch32/mount}} to match the mounts created within {{ic|/usr/local/bin/arch32}}.
  
== Using Schroot to run a 32-bit application ==
+
=== Using Schroot to run a 32-bit application ===
  
 
The general syntax for calling an application ''inside'' the chroot is:
 
The general syntax for calling an application ''inside'' the chroot is:
  
  schroot -p -- htop
+
  # schroot -p -- htop
  
 
In this example, htop is called from within the 32-bit environment.
 
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 {{ic|/etc/makepkg.conf}}.
 
Ensure the desired options are set in the local {{ic|/etc/makepkg.conf}}.
  
 
Some packages may require a {{ic|--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 {{ic|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:
+
===Video problems===
chmod 666 /dev/null
+
  
===Video issues===
 
 
If you get:
 
If you get:
 +
 
  X Error of failed request: BadLength (poly request too large or internal Xlib length error)
 
  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.)===
+
while trying to run an application that requires video acceleration, make sure you have installed appropriate [[video drivers]] in your chroot.
 +
 
 +
=== Sound in Flash ===
  
 
To get sound from the flash player in Firefox, open a terminal and chroot inside the 32-bit system:
 
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:
+
# chroot /opt/arch32
pacman -S alsa-oss
+
 
 +
From there, install {{Pkg|alsa-oss}} as usual with [[pacman]].
  
 
Then type:
 
Then type:
  export FIREFOX_DSP="aoss"
+
 
 +
  $ 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.
 
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.
Line 258: Line 231:
 
For [[Wine]] this works the same way. The package alsa-oss will also install the alsa libs required by [[Wine]] to output sound.
 
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==
+
== Tips and tricks ==
===Java in a chroot===
+
 
See [[Java]] for installation instructions.
+
=== Java in a chroot ===
 +
 
 +
See [[Java]]. After installation, adjust the path:
 +
 
 +
$ export PATH="/opt/java/bin/:$PATH"
 +
 
 +
=== Allow 32-bit applications access to 64-bit PulseAudio ===
 +
 
 +
Additional paths have to be bind-mounted to the chroot environment:
 +
 
 +
# mount --bind /var/run /opt/arch32/var/run
 +
# mount --bind /var/lib/dbus /opt/arch32/var/lib/dbus
  
After installing, adjust the path to get Java working:
+
Unmount them when leaving the environment:
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 [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===
+
# umount /opt/arch32/var/run
 +
# umount /opt/arch32/var/lib/dbus
  
Add these lines in {{ic|/etc/rc.d/arch32}}, above {{ic|add_daemon arch32}}:
+
Optionally add the commands to the {{ic|/usr/local/bin/arch32}} script after the other bind-mount/umount commands. See [[PulseAudio/Examples#PulseAudio_from_within_a_chroot_.28e.g._32-bit_chroot_in_64-bit_install.29|PulseAudio from within a chroot]] for details
mount --bind /var/run /opt/arch32/var/run
+
mount --bind /var/lib/dbus /opt/arch32/var/lib/dbus
+
  
And above {{ic|rm_daemon arch32}}:
+
=== Sound in Firefox ===
umount /opt/arch32/var/run
+
umount /opt/arch32/var/lib/dbus
+
  
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]].
+
Create {{ic|/usr/bin/firefox32}} as root:
  
===Enabling sound in Firefox===
 
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"
  
 
Make it executable:
 
Make it executable:
  sudo chmod +x /usr/bin/firefox32
+
 
 +
  # chmod +x /usr/bin/firefox32
  
 
Now you can make an alias for Firefox, if desired:
 
Now you can make an alias for Firefox, if desired:
 +
 
  alias firefox="firefox32"
 
  alias firefox="firefox32"
  
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.
+
Add this to {{ic|~/.bashrc}} and source it to enable it. 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===
+
=== 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:
+
You need to install the corresponding package under your "native" arch for 3D support.
pacman -S xf86-video-ati libgl ati-dri
+
  
For more informations on how to set up your graphic adapter refer to:
+
For information on how to set up your graphic adapter refer to:
  
[[ATI]]
+
* [[ATI]]
 +
* [[Intel]]
 +
* [[NVIDIA]]
  
[[Intel]]
+
=== WINE ===
  
[[NVIDIA]]
+
{{Out of date|The ''wine-hacks'' package does not exist anymore.}}
  
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 [http://art.ified.ca/?page_id=40 PulseAudio] working. See also [https://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 {{ic|~/.bashrc}}:
 
Add the following alias to {{ic|~/.bashrc}}:
 +
 
  alias wine='schroot -pqd "$(pwd)" -- wine'
 
  alias wine='schroot -pqd "$(pwd)" -- wine'
 +
 
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}}.
 
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}}.
 +
 +
=== Printing ===
 +
 +
{{Accuracy|The note below contains a link to this very page, making it very unclear.}}
 +
 +
{{note|If you have a 64-bit base installation with a [[Install_bundled_32-bit_system_in_Arch64|32-bit chroot environment]], explicit installation of CUPS is not necessary in the 32-bit environment.}}
 +
 +
To access installed CUPS printers from the chroot environment, one needs to bind the {{ic|/var/run/cups}} directory to the same (relative) location in the chroot environment.
 +
 +
Simply make sure the {{ic|/var/run/cups}} directory exists in the chroot environment and bind-mount the host {{ic|/var/run/cups}} to the chroot environment:
 +
 +
# mkdir ''chroot32-dir/var/run/cups''
 +
# mount --bind /var/run/cups ''chroot32-dir/var/run/cups''
 +
 +
and printers should be available from 32-bit chroot applications immediately.

Latest revision as of 21:19, 13 December 2015

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.

Tip: Xyne has created a package that installs a minimalist 32-bit chroot as described below. See [1] and [2] for details.

Installation

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' -e '/Architecture/ s,auto,i686,'  /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 enabled it, in the /opt/arch32/pacman.conf file

3. Create the directory:

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

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

Optionally add your favorite text editor and distcc if you plan to compile within the chroot with other machines:

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

Optionally move the pacman mirror list into place:

# mv /opt/arch32/mirrorlist /opt/arch32/etc/pacman.d

Settings

Key configuration files should be copied over:

# for i in passwd* shadow* group* sudoers resolv.conf localtime locale.gen vimrc mtab inputrc profile.d/locale.sh; do cp -p /etc/"$i" /opt/arch32/etc/; done

Remember to define the correct the number of MAKEFLAGS and other vars in /opt/arch32/etc/makepkg.conf before attempting to build.

Daemon 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

## User variables.
MOUNTPOINT=/opt/arch32

## Set MANAGEPARTITION to any value if /opt/arch32 resides on a separate
## partition and not mounted by /etc/fstab or some other means.
## If /opt/arch32 is part of your rootfs, leave this empty.
MANAGEPARTITION=

## Leave USEDISTCC empty unless you wish to use distccd from within the chroot.
USEDISTCC=
DISTCC_SUBNET='10.9.8.0/24'

## PIDFILE shouldn't need to ba changed from this default.
PIDFILE=/run/arch32

start_distccd() {
	[[ ! -L "$MOUNTPOINT"/usr/bin/distccd-chroot ]] &&
		ln -s /usr/bin/distccd "$MOUNTPOINT"/usr/bin/distccd-chroot 
	DISTCC_ARGS="--user nobody --allow $DISTCC_SUBNET --port 3692 --log-level warning --log-file /tmp/distccd-i686.log"

	[[ -z "$(pgrep distccd-chroot)" ]] &&
		linux32 chroot "$MOUNTPOINT" /bin/bash -c "/usr/bin/distccd-chroot --daemon $DISTCC_ARGS"
}

stop_distccd() {
	[[ -n "$(pgrep distccd-chroot)" ]] &&
		linux32 chroot "$MOUNTPOINT" /bin/bash -c "pkill -SIGTERM distccd-chroot"
}

case $1 in
	start)
		[[ -f "$PIDFILE" ]] && exit 1

		if [[ -n "$MANAGEPARTITION" ]]; then
			mountpoint -q $MOUNTPOINT || mount LABEL="arch32" $MOUNTPOINT
		fi

		dirs=(/tmp /dev /dev/pts /home)
		for d in "${dirs[@]}"; do
			mount -o bind $d "$MOUNTPOINT"$d
		done

		mount -t proc none "$MOUNTPOINT/proc"
		mount -t sysfs none "$MOUNTPOINT/sys"
		touch "$PIDFILE"
		[[ -n "$USEDISTCC" ]] && start_distccd
		;;

	stop)
		[[ ! -f "$PIDFILE" ]] && exit 1
		[[ -n "$USEDISTCC" ]] && stop_distccd

		if [[ -n "$MANAGEPARTITION" ]]; then
			umount -R -A -l "$MOUNTPOINT"
		else
			dirs=(/home /dev/pts /dev /tmp)
			[[ -n "$USEDISTCC" ]] && stop_distccd
			umount "$MOUNTPOINT"/{sys,proc}
			for d in "${dirs[@]}"; do
				umount -l "$MOUNTPOINT$d"
			done
		fi
		
		rm -f "$PIDFILE"
		;;
	*)
		echo "usage: $0 (start|stop)"
		exit 1
esac

Be sure to make the init script executable:

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

Start and optionally enable arch32.service.

Configuration

Chroot into the new system:

# /usr/local/bin/arch32 start
$ xhost +SI:localuser:username_to_give_access_to
# 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.

First-time Setup

Fix possible locale problems:

# /usr/bin/locale-gen

Initialize pacman:

# sed -i 's/CheckSpace/#CheckSpace/' /etc/pacman.conf
# pacman-key --init && pacman-key --populate archlinux

Schroot

Install schroot to the native 64-bit installation:

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 /usr/local/bin/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.

Video problems

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.

Sound in Flash

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 as usual with pacman.

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. After installation, adjust the path:

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

Allow 32-bit applications access to 64-bit PulseAudio

Additional paths have to be bind-mounted to the chroot environment:

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

Unmount them when leaving the environment:

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

Optionally add the commands to the /usr/local/bin/arch32 script after the other bind-mount/umount commands. See PulseAudio from within a chroot for details

Sound in Firefox

Create /usr/bin/firefox32 as root:

#!/bin/sh
schroot -p firefox $1;export FIREFOX_DSP="aoss"

Make it executable:

# chmod +x /usr/bin/firefox32

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

alias firefox="firefox32"

Add this to ~/.bashrc and source it to enable it. Or you can just change all your desktop environment's launchers to firefox32 if you still want 64-bit Firefox to be available.

3D acceleration

You need to install the corresponding package under your "native" arch for 3D support.

For information on how to set up your graphic adapter refer to:

WINE

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: The wine-hacks package does not exist anymore. (Discuss in Talk:Install bundled 32-bit system in 64-bit system#)

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.

Printing

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: The note below contains a link to this very page, making it very unclear. (Discuss in Talk:Install bundled 32-bit system in 64-bit system#)
Note: If you have a 64-bit base installation with a 32-bit chroot environment, explicit installation of CUPS is not necessary in the 32-bit environment.

To access installed CUPS printers from the chroot environment, one needs to bind the /var/run/cups directory to the same (relative) location in the chroot environment.

Simply make sure the /var/run/cups directory exists in the chroot environment and bind-mount the host /var/run/cups to the chroot environment:

# mkdir chroot32-dir/var/run/cups
# mount --bind /var/run/cups chroot32-dir/var/run/cups

and printers should be available from 32-bit chroot applications immediately.