My *nix world

Gentoo 32-bit chroot environment on amd64 no-multilib

I have a Gentoo amd64 no-multilib configuration and sometimes I really need to run 32-bit application (Skype or Android SDK that are available only for 32bit environment).

For these I have prepared a 32-bit chroot-ed environment as specified in 32Bit Chroot Guide for Gentoo/AMD64.

Inside the 32-bit chroot environment I want to use the XServer with Xfce desktop environment. To make sure I will have a basic Xfce environment as I already have in the amd64 environment, I just copied the /etc/make.conf file to /mnt/gentoo32/etc/make.conf and I have adjust few options (tunned for my 32-bit virtual environment)

Gentoo 32-bit chroot environment on amd64 no-multilib

Also, I have configured the /mnt/gentoo32/etc/portage/package.use and /mnt/gentoo32/etc/portage/package.keywords configuration files with those options necessary to build my 32-bit environment:

package.use

package.keywords

In the virtual 32-bit environment I have installed just those applications I will really need, such as:

  • app-admin/sudo
  • app-editors/nano
  • app-emulation/wine
  • app-emulation/winetricks
  • app-portage/gentoolkit
  • dev-util/ccache
  • net-im/skype
  • gnome-extra/zenity
  • x11-base/xorg-drivers
  • x11-base/xorg-server
  • x11-terms/terminal
  • xfce-base/thunar
  • xfce-base/xfce4-meta
  • xfce-extra/thunar-archive-plugin
  • xfce-extra/thunar-volman
  • xfce-extra/tumbler

For building the above 32-bit application within the chroot-ed environment just chroot inside the 32-bit environment (eg: sudo linux32 chroot /mnt/gentoo32/ /bin/bash) and run (as root) the command below:

emerge -DuN world

After several minutes/hours (this depends on your hardware) you should have a 32-bit environment with everythig that is need it for running a XServer with Xfce desktop environment.

Inside the chroot-ed environment create the following file in the home directory of user (eg: /mnt/gentoo//):

.bashrc

Inside the chroot-ed environment create a file named 90xsession in the /etc/env.d/ folder:

Now, if you issue the X command at the console within the chroot-ed environment, it should start the XServer and launch the Xfce desktop environment for you. When you logoff from the Xfce session it should return to the console within the chroot-ed environment.

Let's automate little bit the way we get into the chroot environment and how we launch the Xfce session on that environment!

Instead of mounting/unmounting the virtual filesystem (as described in step 2.c) I have created a bash script which will help me to:

  • automatically mount the necessary folders/devices for my chroot environment virtual file system
  • copy the necessary configuration files into the chroot-ed environment (eg: resolv.conf, hosts, passwd)
  • enter to 32-bit chroot-ed environment and login as prefered user
  • start Xfce session (or whatever program from the chrooted environment) in the chroot-ed environment on display 1 (or even on the display 0), so both sessions - the amd64 default Xfce session and the newly created chroot-ed 32bit Xfce session - are available simultaneously (switch between them with Ctrl+Alt+Fn, where n could be 7,8,...); if you started just a program on current display (eg: display 0) then no switch available/need it
  • exit cleanly from chroot-ed environment and umount previously mounted folders for the virtual file system

So just launching the bash script it will create automatically for you the chroot environment and will start a new X session on another virtual display (eg: display 1). You can, as explained above, work on both sessions, but you have to switch between them with Ctrl+Alt+Fn keys.

First create a bash script called gentoo32 as bellow:

Note: in the above script (1) /gentoo32> should be your linux folder where you have installed the chrooted environment.

When you will run the above script it will ask you for root password (mount requires root authentification), will open automatically the 32-bit chroot-ed environment, will ask you the password for the and then will launch Xfce session for you. When you will logoff from the X session within the chroot-ed environment, the same script will take care of exiting from the chroot-ed environment, unmounting previously mounted folders. So everything is lean and clean...

Examples:

  • launch Xfce session in the chrooted environment:

gentoo32 --service=start --command="startxfce4"--":1" --user=myname

  • launch Eclipse application without starting a separate 32-bit Xfce session, on the same display (eg: display 0) as the main Xfce 64-bit session:

gentoo32 --service=start --command="eclipse" -d 0 --user=myname

  • launch Skype application without starting a separate 32-bit Xfce session, on the same display (eg: display 0) as the main Xfce 64-bit session:

gentoo32 --service=start --command="skype" -d 0 --user=myname

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

 
The following two tabs change content below.
Gentoo 32-bit chroot environment on amd64 no-multilib

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Gentoo 32-bit chroot environment on amd64 no-multilib

Latest posts by Eugen Mihailescu (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: