Difference between revisions of "32-bit Chroot/es"

From Funtoo
Jump to navigation Jump to search
(Created page with "Para lograr esto, primero debe crear los directorios necesarios dentro de la carpeta chroot de 32 bits. Más tarde, las carpetas del host se unirán en estos directorios vací...")
(Created page with "{{package|sys-apps / portage}} y otros paquetes solo deben ver las variables de entorno del chroot de 32 bits y no las del host de 64 bits. La guía de Gentoo requiere que los...")
Line 60: Line 60:
}}
}}


{{package|sys-apps/portage}} and other packages must only see the environment variables of the 32-bit chroot and not those of the 64-bit host. The Gentoo guide requires users to execute {{c|env-update}} each time you enter the 32-bit chroot environment. The following configuration will set this to occur automatically.
{{package|sys-apps / portage}} y otros paquetes solo deben ver las variables de entorno del chroot de 32 bits y no las del host de 64 bits. La guía de Gentoo requiere que los usuarios ejecuten {{c|env-update}} cada vez que ingresen al entorno chroot de 32 bits. La siguiente configuración establecerá que esto ocurra automáticamente.


Create and edit the file {{f|.bash_profile}} inside of the directory {{f|/part/to/chroot/directory/root/}} to include the following
Create and edit the file {{f|.bash_profile}} inside of the directory {{f|/part/to/chroot/directory/root/}} to include the following

Revision as of 08:11, April 13, 2020

Desde la versión 1.3 Funtoo Linux termina el soporte para las aplicaciones de 32 bits y las bibliotecas de x86-64 con multilib -- Para más información mire este post en los foros. Esta página le proporcionará detalles de porque se tomó esta desición y algunos pasos que pueden ser utilizados para obtener soporte de 32 bits sin multilib, mejor conocido como un entorno chroot de 32 bits.

Preámbulo

La x86 Instruction Set Architecture incluye registros 64-bit que se han implementado en los procesadores, desde AMD, Intel y otros comenzando desde el 2003 (AMD Opteron).

Desde entonces, la mayoría de las aplicaciones nuevas y existentes se han escrito para utilizar la arquitectura x86-64bit. Menos aplicaciones requieren soporte de 32 bits. En el pasado, la arquitectura x86-64bit en Funtoo Linux ha brindado soporte para aplicaciones y bibliotecas de 64 y 32 bits simultáneamente, llamado 'multilib', que es una de las capacidades que forman parte de la biblioteca GNU C y el cargador dinámico de bibliotecas.

Sin embargo, el soporte multilib hace que el mantenimiento de los ebuilds sea más complejo, y hemos tenido instrucciones de 64 bits durante más de 15 años, y cada vez menos cosas realmente necesitan soporte de 32 bits. Por lo tanto, tiene sentido comenzar a realizar la transición a un entorno puro de 64 bits sin multilib para reducir la complejidad de los ebuilds, y analizar otros enfoques para resolver el problema de compatibilidad de 32 bits.

Opciones

Los usuarios que necesitan ejecutar programas de 32 bits en hardware x86-64bit tienen varias opciones:

  1. Instalar una segunda instancia separada de Funtoo Linux usando construcciones de arquitectura x86-32bit.
  2. Instalar una instancia de arquitectura x86-32bit de Funtoo Linux en un host x86-64bit. Luego, los usuarios entran en el entorno de 32 bits usando el comando linux32 (es decir, setarch) proporcionado por No results. Esta guía detallará la configuración y el uso de este segundo escenario.
  3. Usar LXD para configurar un contenedor de 32 bits.

Consulte Chroot and Containers para obtener una lista completa de las opciones documentadas en la wiki.

Instalación

Esta guía describe un chroot de 32 bits instalado en un nuevo directorio en el almacenamiento existente.

user $ su -
Password:
root # mkdir -p /path/to/chroot/directory
root # cd /path/to/chroot/directory

Similar a una instalación de Funtoo, se debe descargar y extraer un tarball Stage3 apropiado. Esto proporcionará los directorios, archivos y enlaces necesarios para el chroot de 32 bits.

Consulte la página Subarches para obtener un Stage3 apropiado de 32 bits. Las siguientes compilaciones x86-32bit serían apropiadas en un host x86-64bit

SubarchCPU Family
Generic 3232-bit Processors (PC-Compatible, Generic)
I68632-bit Processors (PC-Compatible, Generic)
Atom 3232-bit Intel Processors
Pentium432-bit Intel Processors

Debe elegir una sub-arquitectura de 32 bits con características y CPU_FLAGS que sean compatibles con el subarchivo y la CPU de su host x86-64bit. En caso de duda, elija la opción ' Generic 32 '.

Copie el enlace de descarga para la construcción 1.3-release-std y péguelo en su terminal para descargarlo usando wget.

root # wget https://build.funtoo.org/1.3-release-std/x86-32bit/generic_32/2018-12-13/stage3-generic_32-1.3-release-std-2018-12-13.tar.xz

Desde su directorio chroot de 32 bits, ejecute el siguiente comando para extraer el tarball Stage3, conservando los permisos:

root # tar -xpf stage3-generic_32-1.3-release-std-2018-12-13.tar.xz

En lugar de tener árboles de portage duplicados, este chroot de 32 bits utilizará el meta-repositorio del host de 64 bits. Para eliminar aún más las descargas duplicadas, también puede usar el directorio de archivos fuente Portage local en el host dentro del chroot (consulte 'DISTDIR' en emerge --info). Los archivos fuente del paquete ya obtenidos por el host estarán disponibles para su uso por parte de Portage dentro del chroot.

Para lograr esto, primero debe crear los directorios necesarios dentro de la carpeta chroot de 32 bits. Más tarde, las carpetas del host se unirán en estos directorios vacíos.

root # mkdir -p var/git/meta-repo
root # mkdir -p var/cache/portage/distfiles

No results y otros paquetes solo deben ver las variables de entorno del chroot de 32 bits y no las del host de 64 bits. La guía de Gentoo requiere que los usuarios ejecuten env-update cada vez que ingresen al entorno chroot de 32 bits. La siguiente configuración establecerá que esto ocurra automáticamente.

Create and edit the file .bash_profile inside of the directory /part/to/chroot/directory/root/ to include the following

root # nano root/.bash_profile
   .bash_profile - /root/.bash_profile inside of /path/to/chroot/directory/
#run env-update on 32-bit chroot login
env-update

As the last step you should configure app-shells/bash to display a modified command prompt while inside of the chroot environment. This will help you to identify when you are issuing commands inside of the 32-bit chroot as opposed to the x86-64bit host.

Add the following line at the end of the file profile inside of the directory /part/to/chroot/directory/etc/

root # nano etc/profile
   profile - /etc/profile inside of /path/to/chroot/directory/
# understand sequences such as \h, don't put anything special in it.
        PS1="${USER:-$(whoami 2>/dev/null)}@$(uname -n 2>/dev/null) \$ "
fi

# ADD THE FOLLOWING LINE TO IDENTIFY YOUR 32-BIT CHROOT ENVIRONMENT
PS1="(32-bit chroot) ${PS1}"

for sh in /etc/profile.d/*.sh ; do
        [ -r "$sh" ] && . "$sh"
done
unset sh

OpenRC Configuration

You can create an sys-apps/openrc service named chroot32 to automatically copy files and mount directories prior to accessing the 32-bit chroot environment. This service will include additional mounts for meta-repo and the Portage DISTDIR.

   Note

The following file mounts Funtoo portage tree /var/git/meta-repo as read-only. The Portage DISTDIR (/var/cache/portage/distfiles) is mounted read-write.

Create and edit the file /etc/init.d/chroot32, setting chroot_dir to equal /path/to/chroot/directory.

root # nano /etc/init.d/chroot32
   chroot32 - /etc/init.d/chroot32 on x86-64bit host
#!/sbin/openrc-run

chroot_dir=/path/to/chroot/directory

depend() {
   need localmount bootmisc
}

start() {
    ebegin "Mounting 32-bit chroot directories"
    mount --rbind /dev "${chroot_dir}/dev" >/dev/null
    mount --rbind /sys "${chroot_dir}/sys" >/dev/null
    mount -t proc none "${chroot_dir}/proc" >/dev/null
    mount -o bind /tmp "${chroot_dir}/tmp" >/dev/null
    mount -o bind,ro /var/git/meta-repo "${chroot_dir}/var/git/meta-repo/" >/dev/null
    mount -o bind /var/cache/portage/distfiles "${chroot_dir}/var/cache/portage/distfiles/" >/dev/null
    mount -t tmpfs -o nosuid,nodev,noexec,mode=755 none "${chroot_dir}/run" > /dev/null
    eend $? "An error occured while attempting to mount 32bit chroot directories"
    ebegin "Copying 32bit chroot files"
    cp -pf /etc/resolv.conf /etc/passwd /etc/shadow /etc/group \
           /etc/gshadow /etc/hosts "${chroot_dir}/etc" >/dev/null
    cp -Ppf /etc/localtime "${chroot_dir}/etc" >/dev/null
    eend $? "An error occured while attempting to copy 32 bits chroot files."
}

stop() {
    ebegin "Unmounting 32-bit chroot directories"
    umount -fR "${chroot_dir}/dev" >/dev/null
    umount -fR "${chroot_dir}/sys" >/dev/null
    umount -f "${chroot_dir}/proc" >/dev/null
    umount -f "${chroot_dir}/tmp" >/dev/null
    umount -f "${chroot_dir}/var/git/meta-repo/" >/dev/null
    umount -f "${chroot_dir}/var/cache/portage/distfiles/" >/dev/null
    umount -f "${chroot_dir}/run"
    eend $? "An error occured while attempting to unmount 32bit chroot directories"
}

Set this file to be executable.

root # chmod +x /etc/init.d/chroot32

Start the chroot32 service to prepare the 32-bit environment.

root # rc-service chroot32 start
 | * Mounting 32-bit chroot directories...                        [ ok ]
 | * Copying 32bit chroot files...                                [ ok ]
   Tip

If you would like this service to run during host startup issue the following command

root # rc-update add chroot32 default
 * service chroot32 added to runlevel default

The 32-bit chroot environment is now ready for access.

Enter 32-bit Chroot

Enter the 32-bit chroot environment with the following commands

user $ su -
Password: *******
root # linux32 chroot /path/to/chroot/directory /bin/bash -l
>>> Regenerating /etc/ld.so.cache...
chroot32 #
   Important

The switch -l tells bash to source /etc/profile within the chroot environment and not from the host. Without this switch you must manually issue the command source /etc/profile each time you enter the 32-bit environment.

Confirm that you are now in a 32-bit environment

chroot32 # uname -m
i686
chroot32 # epro show

=== Enabled Profiles: ===

        arch: x86-32bit
       build: current
     subarch: generic_32
      flavor: core
     mix-ins: (not set)


=== Python kit: ===

      branch: 3.7-release

=== All inherited flavor from core flavor: ===

                         minimal (from core flavor)

Chroot First Steps

If necessary now is a good point to set up Localization. Similarly, changes to /etc/portage/make.conf within the 32-bit environment can be made.

Currently you are the root user inside of the 32-bit environment. To change to the host user account localuser you must first create a home directory for localuser inside the 32-bit environment. (/home/localuser on the host is not mounted inside of this chroot environment.)

chroot32 # cp -r /etc/skel /home/localuser
chroot32 # chown -R localuser:localuser /home/localuser

Switch to 'localuser'

chroot32 # su localuser -l
user $

Updating Funtoo Meta-Repo

   Warning

The 32-bit chroot environment uses the Meta-Repo (/var/git/meta-repo) of the 64bit host. Issuing ego sync is not necessary within the 32-bit chroot environment.

You must update Meta-Repo on the x86-64bit host before entering the 32-bit environment.

Exiting the 32-bit Chroot

chroot32 # exit
root #

Emerging Packages

Enter the 32-bit chroot environment and install packages normally.

user $ su -
Password: *******
root # chroot /path/to/chroot/directory /bin/bash -l
>>> Regenerating /etc/ld.so.cache...
chroot32 # emerge -av foobar
   Tip

Depending on your use case it may be beneficial to change flavor and add mix-ins within the 32-bit environment.

Wine (32-bit only)

   Important

Before entering the 32-bit environment run the following command

user $ su -
Password: *******
root # xhost local:localhost

This will allow X11 applications inside of the 32-bit environment to display on the host X session.

Install Wine inside of the 32-bit environment (example, No results)

chroot32 # emerge -av wine-vanilla

Instead of running wine as the root user, run as localuser. Switch to 'localuser' and configure Wine with winecfg. An X window should display.

chroot32 # su localuser -l
chroot32 # winecfg

Acknowledgement

The information published here is based on steps detailed on the Gentoo Linux Wiki: https://wiki.gentoo.org/wiki/Project:AMD64/32-bit_Chroot_Guide (CC BY-SA 3.0).