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

From ArchWiki
Jump to: navigation, search
(Install and Configure Schroot: updated with new profile key since script-config key is out-dated and throws warnings upon execution)
m (link to talk)
 
(119 intermediate revisions by 24 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-hans:Install bundled 32-bit system in 64-bit system]]
{{Article summary text|
+
{{Archive|1=https://www.archlinux.org/news/phasing-out-i686-support/|2=ArchWiki:Requests#Drop of i686 support}}
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}}
+
  
==Install the Base 32-bit System==
+
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.
1. Create the directory:
+
{{bc|mkdir /opt/arch32}}
+
  
2. Generate temporary [[pacman]] configuration files for chroot:
+
== Installation ==
{{bc|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 ({{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
+
  
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.
+
[[Install]] the {{pkg|arch-install-scripts}} package and create the chroot. Make sure to use a [[pacman]] configuration that does not use the {{ic|[multilib]}} 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}}.
+
# mkdir /opt/arch32
 +
# linux32 pacstrap -C ''path/to/pacman.conf'' -di /opt/arch32 base base-devel
  
Use the {{ic|--config}} switch to tell pacman to use the configuration file generated above, rather than {{ic|/etc/pacman.conf}}.
+
=== Settings ===
  
3. Create the directory, just to be sure:
+
{{Style|"Key" configuration files is subjective}}
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 {{ic|/etc/pacman.d/mirrorlist}} similar to:
 
{{bc|1=# 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:
 
{{bc|1=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 {{ic|/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 Init Script ==
 
 
{{Warning|This included script 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.}}
 
 
To initiate the 32-bit environment at startup, create the following init script {{ic|/etc/rc.d/arch32}}:
 
 
{{bc|<nowiki>#!/bin/bash
 
 
. /etc/rc.conf
 
. /etc/rc.d/functions
 
 
# Add '/var/run /var/lib/dbus' to the list to enable pulseaudio.
 
dirs=(/dev /dev/pts /dev/shm /tmp /home)
 
 
case $1 in
 
    start)
 
        stat_busy "Starting Arch32 chroot"
 
        for d in "${dirs[@]}"; do
 
        mount -o bind $d /opt/arch32$d
 
        done
 
        mount -t proc none /opt/arch32/proc
 
        mount -t sysfs none /opt/arch32/sys
 
        add_daemon arch32
 
        stat_done
 
        ;;
 
    stop)
 
        stat_busy "Stopping Arch32 chroot"
 
        for (( i = ${#dirs[@]} - 1; i >= 0; i-- )); do
 
        umount "/opt/arch32${dirs[i]}"
 
        done
 
        umount /opt/arch32/{proc,sys}
 
        rm_daemon arch32
 
        stat_done
 
        ;;
 
    restart)
 
        $0 stop
 
        sleep 1
 
        $0 start
 
        ;;
 
    *)
 
        echo "usage: $0 {start|stop|restart}"
 
esac
 
exit 0</nowiki>}}
 
A version of the script for Gentoo Linux (OpenRC) is available here: http://pastebin.com/kHt3440j
 
 
Then allow execution of the script:
 
chmod +x /etc/rc.d/arch32
 
 
And add it to {{ic|/etc/rc.conf}}:
 
DAEMONS=(syslog-ng network netfs '''arch32''' crond)
 
 
==Configure the new system==
 
===Configuration files===
 
 
Key configuration files should be copied over:
 
Key configuration files should be copied over:
  
  cd /opt/arch32/etc
+
  # cd /etc
   
+
  # for i in passwd* shadow* group* sudoers resolv.conf localtime locale.gen vimrc inputrc profile.d/locale.sh; do cp -p /etc/"$i" /opt/arch32/etc/; done
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 ===
+
Remember to define the correct the number of MAKEFLAGS and other vars in {{ic|/opt/arch32/etc/makepkg.conf}} before attempting to build.
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 {{ic|~/.bashrc}}.  In fact, the default Debian .bashrc prompt string contains appropriate logic to report whether the working directory is within a chroot.
+
== Configuration ==
  
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}}.
+
# linux32 arch-chroot /opt/arch32
  
Fix possible locale issues:
+
{{Note|If access to the [[Xorg]] server of the host is required, allow it for a given user with {{ic|xhost +si:localuser:''chroot_user''}}. See {{man|7|Xsecurity|url=https://www.x.org/releases/X11R7.7/doc/man/man7/Xsecurity.7.xhtml}} for details.}}
/usr/sbin/locale-gen
+
  
Install the needed packages including apps, fonts, etc. for example:
+
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 {{ic|ARCH32}} string to the {{ic|PS1}} variable defined in {{ic|~/.bashrc}}.
  
pacman -S acroread opera
+
== Schroot ==
pacman -S firefox
+
pacman -S flashplugin
+
pacman -S mplayer-plugin
+
  
Regain space by removing some unnecessary packages.
+
[[Install]] {{Pkg|schroot}} to the native '''64-bit''' installation:
 
+
{{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 {{ic|/etc/schroot/schroot.conf}}, and create an ''[Arch32]'' section.
 
Edit {{ic|/etc/schroot/schroot.conf}}, and create an ''[Arch32]'' section.
Line 179: Line 51:
 
  aliases=32,default
 
  aliases=32,default
  
Optionally edit {{ic|/etc/schroot/arch32/mount}} to match the mounts created within {{ic|/etc/rc.d/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===
+
===Video problems===
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:
+
If you get:
./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.
+
  
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)
 
  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.
  
To get sound from the flash player in Firefox, open a terminal and chroot inside the 32-bit system:
+
=== Sound in Flash ===
chroot /opt/arch32
+
  
From there, install alsa-oss:
+
[[Install]] the {{Pkg|alsa-oss}} package inside the chroot, and export the {{ic|FIREFOX_DSP}} [[environment variable]] before launching [[Firefox]]:
pacman -S alsa-oss
+
  
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 requires this environment variable.
  
Finally, launch Firefox.
+
For [[Wine]] this works the same way. The alsa-oss package will also install the alsa libraries 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 ===
===Java in a chroot===
+
See [[Java]] for installation instructions.
+
  
After installing, adjust the path to get Java working:
+
See [[Java]]. After installation, adjust the path:
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 [http://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===
+
$ export PATH="/opt/java/bin/:$PATH"
  
Add these lines in {{ic|/etc/rc.d/arch32}}, above {{ic|add_daemon arch32}}:
+
=== Allow 32-bit applications access to 64-bit PulseAudio ===
mount --bind /var/run /opt/arch32/var/run
+
mount --bind /var/lib/dbus /opt/arch32/var/lib/dbus
+
  
And above {{ic|rm_daemon arch32}}:
+
Additional paths have to be bind-mounted to the chroot environment:
umount /opt/arch32/var/run
+
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].
+
# mount --bind /var/run /opt/arch32/var/run
 +
# mount --bind /var/lib/dbus /opt/arch32/var/lib/dbus
  
===Enabling sound in Firefox===
+
Unmount them when leaving the environment:
Open a text editor and save the following in {{ic|/usr/bin/firefox32}} as root:
+
#!/bin/sh
+
schroot -p firefox $1;export FIREFOX_DSP="aoss"
+
  
Make it executable:
+
# umount /opt/arch32/var/run
  sudo chmod +x /usr/bin/firefox32
+
  # umount /opt/arch32/var/lib/dbus
  
Now you can make an alias for Firefox, if desired:
+
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
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.
+
=== Sound in Firefox ===
  
===Enabling 3D acceleration===
+
Create {{ic|/usr/bin/firefox32}} as root:
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:
+
#!/bin/sh
  pacman -S xf86-video-ati libgl ati-dri
+
  schroot -p firefox $1;export FIREFOX_DSP="aoss"
  
For more informations on how to set up your graphic adapter refer to:
+
Make it executable:
 
+
[[ATI]]
+
 
+
[[Intel]]
+
  
[[NVIDIA]]
+
# chmod +x /usr/bin/firefox32
  
Your can easily check if you have 3D rendering within the 32 bit chroot by installing mesa-demos and running the following command:
+
=== Printing ===
  glxinfo | grep renderer
+
  
If you have no 3D acceleration you'll get some output like this:
+
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.
  [joe@arch64]$ OpenGL renderer string: Software Rasterizer
+
  
If 3D acceleration is enabled you'll get a message like this:
+
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:
  [joe@arch64]$ OpenGL renderer string: Mesa DRI R600 (RV730 9490) 20090101 x86/MMX+/3DNow!+/SSE2 TCL DRI2
+
  
===Script for wine===
+
# mkdir /opt/arch32/var/run/cups
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.
+
# mount --bind /var/run/cups /opt/arch32/var/run/cups
  
Add the following alias to {{ic|~/.bashrc}}:
+
and printers should be available from 32-bit chroot applications immediately.
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}}.
+

Latest revision as of 08:59, 8 February 2017

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.

Installation

Install the arch-install-scripts package and create the chroot. Make sure to use a pacman configuration that does not use the [multilib] repository.

# mkdir /opt/arch32
# linux32 pacstrap -C path/to/pacman.conf -di /opt/arch32 base base-devel

Settings

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: "Key" configuration files is subjective (Discuss in Talk:Install bundled 32-bit system in 64-bit system#)

Key configuration files should be copied over:

# cd /etc
# for i in passwd* shadow* group* sudoers resolv.conf localtime locale.gen vimrc 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.

Configuration

# linux32 arch-chroot /opt/arch32
Note: If access to the Xorg server of the host is required, allow it for a given user with xhost +si:localuser:chroot_user. See Xsecurity(7) for details.

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.

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

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

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

Install the alsa-oss package inside the chroot, and export the FIREFOX_DSP environment variable before launching Firefox:

$ export FIREFOX_DSP="aoss"

Every chroot into the 32-bit system requires this environment variable.

For Wine this works the same way. The alsa-oss package will also install the alsa libraries 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

Printing

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 /opt/arch32/var/run/cups
# mount --bind /var/run/cups /opt/arch32/var/run/cups

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