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

From ArchWiki
Jump to: navigation, search
(Install the Base 32-bit System: fixed up)
(tl;dr version: No.)
(28 intermediate revisions by 8 users not shown)
Line 8: Line 8:
 
{{Article summary end}}
 
{{Article summary end}}
  
==Install the Base 32-bit System==
+
== Make the i686 Chroot ==
 +
===Install the Base 32-bit System===
  
 
1. Create the directory:
 
1. Create the directory:
{{bc|mkdir /opt/arch32}}
+
mkdir /opt/arch32
  
 
2. Generate temporary [[pacman]] configuration files for chroot:
 
2. Generate temporary [[pacman]] configuration files for chroot:
{{bc|sed -e 's/\$arch/i686/g' /etc/pacman.d/mirrorlist > /opt/arch32/mirrorlist
+
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@/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.
Line 33: Line 34:
 
  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
  
Move pacman configuration files into place:
+
Optionally move the pacman mirror list into place:
 +
mv /opt/arch32/mirrorlist /opt/arch32/etc/pacman.d
  
  mv mirrorlist /opt/arch32/etc/pacman.d
+
===Configuration files===
  sed -i 's/\/opt\/arch32/\/etc\/pacman.d/g' /opt/arch32/pacman.conf && mv /opt/arch32/pacman.conf /opt/arch32/etc/pacman.conf
+
Key configuration files should be copied over:
 +
 
 +
  cd /opt/arch32/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 .
 +
 
 +
Be sure to include the "." character!
 +
 
 +
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 ==
 
== Create an Arch32 Daemon Script and Systemd Service ==
Line 56: Line 76:
 
#!/bin/bash
 
#!/bin/bash
  
# Add '/var/run /var/lib/dbus' to the list to enable pulseaudio.
+
MOUNTPOINT=/opt/arch32
dirs=(/dev /dev/pts /dev/shm /tmp /home)
+
PIDFILE=/run/arch32
 +
 
 +
# Leave this blank if not using distccd from within the chroot.
 +
USEDISTCC=
 +
DISTCC_SUBNET='192.168.0.0/24'
 +
 
 +
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"
 +
 
 +
  if [[ -z "$(pgrep distccd-chroot)" ]]; then
 +
    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() {
 +
  if [[ -n "$(pgrep distccd-chroot)" ]]; then
 +
    linux32 chroot $MOUNTPOINT /bin/bash -c "pkill -SIGTERM distccd-chroot"
 +
  else
 +
    echo "/usr/bin/distccd-chroot does NOT seems to be running so doing nothing!"
 +
  fi
 +
}
  
 
case $1 in
 
case $1 in
    start)
+
  start)
        for d in "${dirs[@]}"; do
+
    # Only relevant for users with an arch32 chroot on a separate partition.
            mount -o bind $d /opt/arch32$d
+
    # Edit to fit your system and take note of the corresponding unmount option in the stop function!
        done
+
    # mountpoint -q $MOUNTPOINT || mount LABEL="arch32" $MOUNTPOINT
        ;;
+
 
    stop)
+
    dirs=(/tmp /dev /dev/pts /home)
        for (( i = ${#dirs[@]} - 1; i >= 0; i-- )); do
+
    for d in "${dirs[@]}"; do
            umount "/opt/arch32${dirs[i]}"
+
      mount -o bind $d $MOUNTPOINT$d
        done
+
    done
        umount /opt/arch32/{proc,sys}
+
 
        ;;
+
    mount -t proc none $MOUNTPOINT/proc
    *)
+
    mount -t sysfs none $MOUNTPOINT/sys
        echo "usage: $0 (start|stop)"
+
    touch $PIDFILE
        exit 1
+
    [[ -n "$USEDISTCC" ]] && start_distccd
esac</nowiki>}}
+
    ;;
 +
  stop)
 +
    dirs=(/home /dev/pts /dev /tmp)
 +
    [[ -n "$USEDISTCC" ]] && stop_distccd
 +
    umount $MOUNTPOINT/{sys,proc}
 +
    for d in "${dirs[@]}"; do
 +
      umount -l "$MOUNTPOINT$d"
 +
    done
 +
    # Only relevant for users with an arch32 chroot on a separate partition.
 +
    # umount -l $MOUNTPOINT
 +
    rm -f $PIDFILE
 +
    ;;
 +
  *)
 +
    echo "usage: $0 (start|stop)"
 +
    exit 1
 +
esac
 +
 
 +
# vim:set ts=2 sw=2 et:
 +
</nowiki>}}
  
 
Be sure to make the init script executable:
 
Be sure to make the init script executable:
Line 82: Line 143:
  
 
==Configure the new system==
 
==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 .
 
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!
 
 
 
=== Configure the chroot ===
 
=== Configure the chroot ===
 
Chroot into the new system:
 
Chroot into the new system:
  /etc/rc.d/arch32 start
+
  /usr/local/bin/arch32 start
 
  xhost +SI:localuser:usernametogiveaccesstogoeshere  
 
  xhost +SI:localuser:usernametogiveaccesstogoeshere  
 
  chroot /opt/arch32
 
  chroot /opt/arch32
Line 109: Line 151:
 
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.
  
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}}.
+
=== First-time Setup ===
 
+
 
Fix possible locale issues:
 
Fix possible locale issues:
 
  /usr/sbin/locale-gen
 
  /usr/sbin/locale-gen
  
 +
Initialize pacman:
 +
sed -i 's/CheckSpace/#CheckSpace/' /etc/pacman.conf
 +
pacman-key --init
 +
pacman-key --populate archlinux
 +
 +
=== Install Needed Packages ===
 
Install the needed packages including apps, fonts, etc. for example:
 
Install the needed packages including apps, fonts, etc. for example:
  
pacman -S acroread opera
 
 
  pacman -S firefox
 
  pacman -S firefox
 
  pacman -S flashplugin
 
  pacman -S flashplugin
pacman -S mplayer-plugin
 
 
Regain space by removing some unnecessary packages.
 
  
 +
=== Regain Space (Optional) ===
 
{{Warning| This cleanup is for the '''32-bit''' root environment and must then be done inside it NOT the native 64-bit environment!}}
 
{{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:
 
The following shows recommended packages for removal:
  
  pacman -Rd linux mkinitcpio
+
  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
pacman -R dhcpcd ppp xfsprogs reiserfsprogs jfsutils logrotate lvm2 pcmciautils netcfg heirloom-mailx iputils iproute2 man-pages mdadm inetutils man-db cronie vi
+
  
 
Also consider regularly clearing out pacman's cache:
 
Also consider regularly clearing out pacman's cache:
Line 151: Line 194:
 
  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 ==
Line 207: Line 250:
 
===Allowing 32-bit applications access to 64-bit Pulseaudio===
 
===Allowing 32-bit applications access to 64-bit Pulseaudio===
  
Add these lines in {{ic|/etc/rc.d/arch32}}, above {{ic|add_daemon arch32}}:
+
Add these lines in {{ic|/usr/local/bin/arch32}}, before the daemon is started:
 
  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 {{ic|rm_daemon arch32}}:
+
And before the daemon is stopped:
 
  umount /opt/arch32/var/run
 
  umount /opt/arch32/var/run
 
  umount /opt/arch32/var/lib/dbus
 
  umount /opt/arch32/var/lib/dbus
Line 231: Line 274:
  
 
===Enabling 3D acceleration===
 
===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.  
+
You need to install the corresponding package under your "native" arch for 3D support.  
  
For an ATI card using the radeon driver this could be:
+
For information on how to set up your graphic adapter refer to:
pacman -S xf86-video-ati libgl ati-dri
+
  
For more informations on how to set up your graphic adapter refer to:
+
* [[ATI]]
 
+
* [[Intel]]
[[ATI]]
+
* [[NVIDIA]]
 
+
[[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===
 
===Script for wine===
Line 259: Line 288:
 
  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===
 +
 +
For accessing CUPS printers intalled in the base system from the chroot environment, see [[CUPS#Installing_CUPS_a_32_bit_chroot_environment|the applicable section]] of the [[CUPS|Arch CUPS Wiki page]].

Revision as of 12:55, 21 June 2013

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

Make the i686 Chroot

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' -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 enable 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

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 .
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!

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

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

MOUNTPOINT=/opt/arch32
PIDFILE=/run/arch32

# Leave this blank if not using distccd from within the chroot.
USEDISTCC=
DISTCC_SUBNET='192.168.0.0/24'

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"

  if [[ -z "$(pgrep distccd-chroot)" ]]; then
    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() {
  if [[ -n "$(pgrep distccd-chroot)" ]]; then
    linux32 chroot $MOUNTPOINT /bin/bash -c "pkill -SIGTERM distccd-chroot"
  else
    echo "/usr/bin/distccd-chroot does NOT seems to be running so doing nothing!"
  fi
}

case $1 in
  start)
    # Only relevant for users with an arch32 chroot on a separate partition.
    # Edit to fit your system and take note of the corresponding unmount option in the stop function!
    # mountpoint -q $MOUNTPOINT || mount LABEL="arch32" $MOUNTPOINT

    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)
    dirs=(/home /dev/pts /dev /tmp)
    [[ -n "$USEDISTCC" ]] && stop_distccd
    umount $MOUNTPOINT/{sys,proc}
    for d in "${dirs[@]}"; do
      umount -l "$MOUNTPOINT$d"
    done
    # Only relevant for users with an arch32 chroot on a separate partition.
    # umount -l $MOUNTPOINT
    rm -f $PIDFILE
    ;;
  *)
    echo "usage: $0 (start|stop)"
    exit 1
esac

# vim:set ts=2 sw=2 et:

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

Configure the chroot

Chroot into the new system:

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

First-time Setup

Fix possible locale issues:

/usr/sbin/locale-gen

Initialize pacman:

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

Install Needed Packages

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

pacman -S firefox
pacman -S flashplugin

Regain Space (Optional)

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 dhcpcd ppp xfsprogs reiserfsprogs jfsutils logrotate lvm2 pcmciautils netcfg heirloom-mailx iputils iproute2 man-pages mdadm inetutils man-db cronie vi

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 /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.

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 /usr/local/bin/arch32, before the daemon is started:

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

And before the daemon is stopped:

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

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:

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.

Printing

For accessing CUPS printers intalled in the base system from the chroot environment, see the applicable section of the Arch CUPS Wiki page.