Difference between revisions of "Arch32"

From ArchWiki
Jump to: navigation, search
(37 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Poor writing}}
+
#REDIRECT [[Install_bundled_32-bit_system_in_Arch64]]
 
+
Note: 32-bit chroot for a 64-bit Arch is described in [[Install_bundled_32-bit_system_in_Arch64]] in great detail.
+
 
+
 
+
First we decide where to place the 32bit system. This variable will be used throughout this page for flexibilty. The given value is just what the author used. If you prefer some other location, this is the time to change it.
+
ARCH32_ROOT="/opt/arch32"
+
Now we have to create the directories so that pacman can function and affect changes inside our chroot.
+
mkdir -p $ARCH32_ROOT/var/{cache/pacman/pkg,lib/pacman}
+
Below is a helper script which I place in /usr/local/bin/pacman32. It will allow us to run pacman from our 64bit install and it will affect our chroot only. Make sure that if you are not using the default location, to change it here.
+
#!/bin/bash
+
ARCH32_ROOT="/opt/arch32"
+
PACMAN_EXEC="pacman"
+
+
+
sed -e 's/x86_64/i686/g' /etc/pacman.d/mirrorlist > $ARCH32_ROOT/mirrorlist
+
sed -e 's@/etc/pacman.d/mirrorlist@/opt/arch32/mirrorlist@g' /etc/pacman.conf > $ARCH32_ROOT/pacman.conf
+
+
$PACMAN_EXEC --root $ARCH32_ROOT --cachedir $ARCH32_ROOT/var/cache/pacman/pkg --config $ARCH32_ROOT/pacman.conf "$@"
+
Now we can sync up our 32bit pacman with the repositories.
+
/usr/local/bin/pacman32 -Sy
+
And then we install the bare-minimum that we need to install other 32bit programs and libraries.
+
/usr/local/bin/pacman32 -S filesystem licenses bash sed coreutils gzip
+
We now setup some of the meaningful configuration files.
+
cd $ARCH32_ROOT/etc
+
+
ln -f /etc/passwd*
+
ln -f /etc/shadow*
+
ln -f /etc/group*
+
ln -f /etc/rc.conf
+
ln -f /etc/resolv.conf
+
ln -f /etc/localtime
+
ln -f /etc/locale.gen
+
ln -f /etc/profile.d/locale.sh profile.d
+
ln -f /etc/vimrc
+
cp /etc/mtab .
+
 
+
/usr/local/bin/arch32
+
#!/bin/bash
+
schroot -p -- "$@"
+
 
+
= Alternative Setup (Testing) =
+
 
+
This setup is being tested and so far seems to work well. It is based on the above comments and the more detailed description in [[Install_bundled_32-bit_system_in_Arch64]].
+
 
+
== Create Folder Structure ==
+
 
+
Create folder to store and sync 32-bit system (as root):
+
 
+
# mkdir /opt/arch32
+
 
+
Create pacman folder structure inside new location:
+
 
+
# mkdir -p /opt/arch32/var/{cache/pacman/pkg,lib/pacman}
+
 
+
== Pacman Configuration ==
+
 
+
Copy the pacman config files from 64-bit system and edit pacman sync files to work as 32-bit system. These two commands will copy and change /etc/pacman.conf and /etc/pacman.d/mirrorlist to be saved in /opt/arch32.
+
 
+
# sed -e 's/x86_64/i686/g' /etc/pacman.d/mirrorlist > /opt/arch32/mirrorlist
+
 
+
# sed -e 's@/etc/pacman.d/mirrorlist@/opt/arch32/mirrorlist@g' -e 's/Architecture = auto/Architecture = i686/g' /etc/pacman.conf > /opt/arch32/pacman.conf
+
 
+
N.B. Check that both files point to i686 mirrors  Line: 'Architecture = i686' in /etc/pacman.conf is correct.
+
 
+
== Sync 32-bit System Using 64-bit Pacman Command ==
+
 
+
Use this pacman command to sync files to correct location in /opt/arch32 from 64-bit system:
+
 
+
# pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -Sy
+
 
+
Once pacman is synchronised, install minimum packages:
+
 
+
# pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf -S filesystem licenses bash sed coreutils gzip pacman (nano make file gawk grep gcc)
+
 
+
Packages in brackets are useful for compiling packages in 32-bit system, e.g. from AUR
+
 
+
Create links in 32-bit system from useful conf files in 64-bit system (some are optional), first change to /opt/arch32/etc directory:
+
 
+
# cd /opt/arch32/etc
+
 
+
Run these commands, including '.' character (during the testing only those marked with required seem to be important)
+
 
+
ln -f /etc/passwd* .
+
ln -f /etc/shadow* .
+
ln -f /etc/group* .
+
ln -f /etc/rc.conf .
+
ln -f /etc/resolv.conf .    '''--> required'''
+
ln -f /etc/localtime .
+
ln -f /etc/locale.gen .    '''--> required'''
+
ln -f /etc/profile.d/locale.sh profile.d
+
ln -f /etc/vimrc .
+
cp /etc/mtab .
+
 
+
== Create Chroot Enviroment Scripts ==
+
 
+
Copy bash script below and save as arch32 in /etc/rc.d/
+
 
+
 
+
#!/bin/bash
+
+
. /etc/rc.conf
+
. /etc/rc.d/functions
+
+
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
+
 
+
 
+
Then make script executable
+
 
+
# chmod +x /etc/rc.d/arch32
+
 
+
Create bash script to chroot into new 32-bit system:
+
 
+
#!/bin/bash
+
+
# Start chroot daemon
+
 
+
sudo /etc/rc.d/arch32 start
+
 
+
# Give users access to xserver
+
+
xhost +
+
(install xorg-xhost if command not found)
+
+
# Chroot into 32-bit system
+
+
sudo chroot /opt/arch32
+
+
# When leaving chroot type 'exit' then following commands will run....
+
+
xhost -
+
+
sudo /etc/rc.d/arch32 stop
+
 
+
 
+
Run bash script arch32.sh to chroot and configure locale
+
 
+
locale-gen
+
 
+
11. a) Uncomment required mirrors in /etc/pacman.d/mirrorlist in chroot
+
    b) Change architecture entry from auto to i686 in /etc/pacman.conf
+
 
+
12. Sync repositories
+
 
+
pacman -Sy
+
 
+
13. No need to setup xorg, only install video drivers and possibly copy xorg.conf file over to arch32 systen.
+

Revision as of 02:18, 11 December 2012