memo

2011-02-16

yum を使って 64bit な CentOS 内に 32bit な chroot 環境を作成する

/chroot-32bit 以下に 32bit な httpd, php をインストールしたいとする。

# mkdir /chroot-32bit
# mkdir -p /chroot-32bit/var/lib/rpm
# # initialize rpm database
# rpm --rebuilddb --root=/chroot-32bit
# # install for yum repos file
# wget http://ftp.jaist.ac.jp/pub/Linux/CentOS/5.5/os/i386/CentOS/centos-release-5-5.el5.centos.i386.rpm
# rpm -i --root=/chroot-32bit --nodeps centos-release-5-5.el5.centos.i386.rpm
warning: centos-release-5-5.el5.centos.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
# # use 32bit(i386)
# sed -i -e 's/\$basearch/i386/g' /chroot-32bit/etc/yum.repos.d/CentOS-Base.repo
# # install httpd, php
# yum --installroot=/chroot-32bit install httpd php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.jaist.ac.jp
 * base: ftp.jaist.ac.jp
 * extras: ftp.jaist.ac.jp
 * updates: ftp.jaist.ac.jp
addons                                                    |  951 B     00:00
addons/primary                                            |  202 B     00:00
base                                                      | 2.1 kB     00:00
base/primary_db                                           | 1.6 MB     00:00
extras                                                    | 2.1 kB     00:00
extras/primary_db                                         | 181 kB     00:00
updates                                                   | 1.9 kB     00:00
updates/primary_db                                        | 915 kB     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.i386 0:2.2.3-43.el5.centos.3 set to be updated
....

Complete
# ls -l /chroot-32bit/usr/sbin/httpd
-rwxr-xr-x 1 root root 315284 Aug 31 01:37 /chroot-32bit/usr/sbin/httpd
# mount -o bind /dev /chroot-32bit/dev
# mount -o bind /proc /chroot-32bit/proc
# linux32 chroot /chroot-32bit /sbin/service httpd start
Starting httpd:                                            [  OK  ]