Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Install 32-bit chroot on 64-bit devuan for compiling i386 packages

By accident, I installed 32-bit devuan instead of 64-bit, so all my self- hosted dpkgs didn't work because they are for x86_64 architecture. So I started trying to compile the dpkgs in the new environment, and one in particular (palemoon) would always exhaust memory. I found a wonderful reference [1] that explains how to set up a 32-bit chroot on 64-bit debian-based GNU/Linux. I tested my adaptation of the instructions on devuan ceres x86_64. Install schroot and debootstrap.

sudo apt-get install schroot debootstrap

Set up schroot.

tf=/etc/schroot/chroot.d/ceres32
touch "${tf}" ; chmod 0644 "${tf}"
cat <<EOF >"${tf}"
[ceres32]
description=Devuan ceres 32-bit
directory=/32
type=directory
personality=linux32
users=bgstack15
groups=users,admin
EOF

Install the new distribution.

mkdir /32
debootstrap --arch i386 ceres /32 http://pkgmaster.devuan.org/merged

Now the chroot is minimally viable, but there are a few recommended steps to take before using it. Symlink in the mtab.

ln -s /proc/mounts /32/etc/mtab

Copy in any system-wide setting as desired.

cp -p /etc/apt/apt.conf /32/etc/apt/      # for proxy settings
cp -p /etc/apt/sources.list /32/etc/apt/  # for universe, security, etc
cp -p /etc/environment /32/etc/           # for proxy and locale settings
cp -p /etc/sudoers /32/etc/               # for custom sudo settings

Disable services in the chroot.

tf=/32/usr/sbin/policy-rc.d
touch "${tf}" ; chmod 0755 "${tf}" ; chown root.root "${tf}" ;
cat <<EOF >"${tf}"
#!/bin/sh
## Don't start any service if running in a chroot.
## See /usr/share/doc/sysv-rc/README.policy-rc.d.gz
if [ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]; then
  exit 101
fi
EOF

Now load up the chroot and prepare a few more packages.

schroot -c ceres32
sudo apt-get update
sudo apt-get install lsb-core

From here, you can install your build dependencies and build i386 dpkgs!

References

Weblinks

  1. Ripped entirely from How do I run 32-bit programs on a 64-bit Debian/Ubuntu? - Unix & Linux Stack Exchange

Comments