The Gentoo Linux 32bit chroot guide will help you setting up a true 32bit chroot for your Gentoo/AMD64 system.
As you know 64bit systems don't run 32bit applications natively yet (at least not with portage) so you need to use emulation libraries to make them working or create a true 32bit system inside a chroot to install and run native 32bit applications. For the most common uses you do not need do build a 32bit chroot system. However, if you want to run applications that don't have a binary available to run with 32bit libraries, you should use a 32bit chroot. This guide will teach you how to set up a 32bit chroot and how to install and run applications inside the chroot.
To install a 32bit chroot you need to follow many footsteps that you use to install Gentoo Linux on a x86 computer. For now you need the latest stage3 available on our
$ cd /home/user/downloads $ wget -c ftp://distfiles.gentoo.org/releases/x86/2006.1/stages/stage3-i686-2006.1.tar.bz2
After downloading the stage3 you need to create a new directory to build your new chroot.
$ su root insert your root password # cd /mnt # mkdir gentoo32
Then move the stage you have already downloaded, unpack it and set it up it like this example.
# cd /mnt/gentoo32 # tar -xvjpf /home/user/downloads/stage3-i686-2006.1.tar.bz2 # cp -L /etc/resolv.conf /mnt/gentoo32/etc/ # cp -L /etc/passwd /mnt/gentoo32/etc/
Now you have the chroot ready for setup. Read the next chapter to learn how to set it up.
If everything went well until here now you will be able to set up your new 32bit chroot and finish the installation of this chroot.
The next step is to setup your new
CFLAGS="-O2 -march=athlon-xp -msse2 -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j2"
Now mount the various bogus file systems:
# mount -o bind /dev /mnt/gentoo32/dev # mount -o bind /dev/pts /mnt/gentoo32/dev/pts # mount -o bind /dev/shm /mnt/gentoo32/dev/shm # mount -o bind /proc /mnt/gentoo32/proc # mount -o bind /proc/bus/usb /mnt/gentoo32/proc/bus/usb # mount -o bind /sys /mnt/gentoo32/sys
Now you have a true 32bit chroot installed in your 64bits system which is almost ready for use. Next, you need to create a link from your portage available in your 64bit system to your chroot. This way, you only need to update it in one installation instead of duplicating a lot of data.
# mkdir -p /mnt/gentoo32/usr/portage/ # mount -o bind /usr/portage /mnt/gentoo32/usr/portage/
If you want to run 32bit applications which use X, you also need to mount /tmp.
# mount -o bind /tmp /mnt/gentoo32/tmp
Now we're ready to switch inside the chroot.
(Only perform this step if you don't have util-linux already installed) # emerge util-linux # linux32 chroot /mnt/gentoo32 /bin/bash (Make sure we have a i686 setup) # uname -m i686
Now you have a new 32bit chroot system ready to be updated. Follow the next steps to update it.
# source /etc/profile # env-update # emerge --sync # emerge -auDN world
After this you basically have finished the setup of your 32bit chroot. To make things more suitable, we are going to set up a new file in your 64bit system to enable the 32bit chroot when booting.
# nano -w /etc/init.d/gentoo32
#!/sbin/runscript
depend() {
need localmount
need bootmisc
}
start() {
ebegin "Mounting 32bit chroot dirs"
mount -o bind /dev /mnt/gentoo32/dev >/dev/null
mount -o bind /dev/pts /mnt/gentoo32/dev/pts >/dev/null &
mount -o bind /dev/shm /mnt/gentoo32/dev/shm >/dev/null &
mount -o bind /proc /mnt/gentoo32/proc >/dev/null
mount -o bind /proc/bus/usb /mnt/gentoo32/proc/bus/usb >/dev/null &
mount -o bind /sys /mnt/gentoo32/sys >/dev/null &
mount -o bind /tmp /mnt/gentoo32/tmp >/dev/null &
mount -o bind /usr/portage /mnt/gentoo32/usr/portage/ >/dev/null &
eend $? "An error occured while attempting to mount 32bit chroot directories"
ebegin "Copying 32bit chroot files"
cp -pf /etc/resolv.conf /mnt/gentoo32/etc >/dev/null &
cp -pf /etc/passwd /mnt/gentoo32/etc >/dev/null &
cp -pf /etc/shadow /mnt/gentoo32/etc >/dev/null &
cp -pf /etc/group /mnt/gentoo32/etc >/dev/null &
cp -pf /etc/gshadow /mnt/gentoo32/etc >/dev/null &
cp -pf /etc/hosts /mnt/gentoo32/etc > /dev/null &
cp -Ppf /etc/localtime /mnt/gentoo32/etc >/dev/null &
eend $? "An error occured while attempting to copy 32 bits chroot files."
}
stop() {
ebegin "Unmounting 32bit chroot dirs"
umount -f /mnt/gentoo32/dev/pts >/dev/null
umount -f /mnt/gentoo32/dev/shm >/dev/null
umount -f /mnt/gentoo32/dev >/dev/null &
umount -f /mnt/gentoo32/proc/bus/usb >/dev/null
umount -f /mnt/gentoo32/proc >/dev/null &
umount -f /mnt/gentoo32/sys >/dev/null &
umount -f /mnt/gentoo32/tmp >/dev/null &
umount -f /mnt/gentoo32/usr/portage/ >/dev/null &
eend $? "An error occured while attempting to unmount 32bit chroot directories"
}
Now you only need to run
Whenever you want to switch to your chroot environment, you only need to run the following command:
Now you have your 32bit chroot ready to install new applications.
Now that you have a fully functional 32bit chroot you can install every application in 32bit mode. Let's see how you can install new packages on your 32bit chroot.
# linux32 chroot /mnt/gentoo32 /bin/bash # source /etc/profile # env-update # emerge foo
You now have installed a new package in your 32bit chroot. If you want to run your new package you need to run it inside of your chroot. If you want to run
X applications the best solution to run it is doing the
# xhost local:localhost
After this get inside your chroot again and you should be able to run every X application you build inside your 32bit chroot.
With this chroot you can install many packages available only for x86 arch. Some packages like