Tiny CentOS 5.5 32 bit (i386)
From WBITT's Cooker!
Contents |
Summary
Based on my previous (unfinished) article on creating a Tiny CentOS distribution, I have created this article. This one is finished (almost).
As I mentioned earlier. The idea is to have an absolute minimum number of packages. The driving force behind this thought is the latest RedHat Virtualization solution, RHEV, or, RedHat Enterprise Virtualization. RHEV is a slim/cut down version of RHEL 6, working as a KVM Hypervisor, with a very small install foot-print. I noticed that it is a similar concept as Citrix XEN Server. So, I wanted to see, if I can be successful in creating a similar product, based on CentOS 5.5. Notice that the procedure explained below DOES NOT contain libvirt, as yet. This is only because I was first interested in creating a distribution as small as possible. Since I have included yum in it, I (and you) can add any other RPM based package to it, without a problem. In coming days however, I will release a (so called) hypervisor version, InshaAllah (God Willing).
CENTOS/RHEL already has a @core group (option), which can be used in the kickstart based installation. Even that takes up considerable space and installs CUPS, SENDMAIL and a lot of other un-necessary packages.
Since I wanted to create a very small list of RPMS. I came up with a plan. I started with kernel, and kept trying to install the related RPMS in a temporary directory using RPM. I continued including missing files (RPMS), which were being reported by RPM as required dependencies. When all dependencies got resolved, I believed I had the desired minimal file list.
When I completed the basic minimal list, I added ssh-server, wget and yum to it. I further added the following: grub (boot loader), openssh-clients (for ssh, scp, sftp, etc), and vim-minimal (editor).
That would essentially make it a working server installation/distribution. Anything else can be added through "yum". The packages size is 108 RPM files (CENTOS), and 124 MB in total.
Note that I (generated and) tested this on a KVM based VM. This list does not include kernel-xen. You should add kernel-xen RPM to the rpm list, if you intend to use it either as XEN host, or XEN VM.
Infrastructure
Physical Host
The physical host is a Fedora 14 machine, with 4 GB RAM, and 200 GB of disk. Out of which about 70 GB is free space.
The disk has a directory /data/cdimages , which hosts various ISO images of different OS, I have. This directory has the following layout (only the part interesting to us is shown below).
[root@fedora14 cdimages]# tree -d . ├── CentOS-5.5-i386 │ ├── CentOS │ ├── images │ │ ├── pxeboot │ │ └── xen │ ├── isolinux │ ├── NOTES │ └── repodata └── CentOS-5.5-i386-tiny
The /data/cdimages/CentOS-5.5-i386 is the full DVD copied in this directory. If you cannot afford to download full DVD, (for perfectly understandable reasons), you can download the packages, directly from the CENTOS website. The method to do so, is already mentioned here: http://cooker.wbitt.com/index.php/CENTOS_Server_CD_project#Creating_the_.22core.22_install-tree_from_a_http_site
The /data/cdimages/CentOS-5.5-i386-tiny directory shown above, is an empty directory. It is possible that you do not have this directory created at this moment. We can create this directory at a later stage.
The directory /data/cdimages on the physical host, is made available as an NFS writeable share to the 192.168.122.0/24 network. As following:
[root@fedora14 cdimages]# cat /etc/exports /data/cdimages 192.168.122.0/255.255.255.0(rw,no_root_squash). [root@fedora14 cdimages]# [root@fedora14 cdimages]# service nfs restart
(Make sure that the firewall is not blocking incoming NFS requests on the physical host).
This is a good method to save space, both on the physical host and on the VMs. That means, you don't have to "fill-up" your build host (VM) will all the DVD/RPM files and ISO images. So they don't need large virtual disks for it. All of the work, can be performed, when we mount this directory /data/cdimages, from the physical host, to the buildhost-32 VM.
The physical host has the IP: 192.168.122.1 , on the virbr0 interface. It may (or may not) have any IP on it's eth0 interface, which is irrelevant to this text.
Build Host
The buildhost (named buildhost-32) is actually a CentOS 5.5 32 bit Virtual Machine running inside a Fedora 14 physical host. It is installed with the minimal installation available with default CENTOS installer. It has additional packages installed on it, which are:
[root@buildhost-32 ~]# yum -y install anaconda anaconda-runtime mkisofs cdrecord
The BuildHost has only 512 MB Virtual Memory, and 2GB Virtual Disk. We basically do not need much disk space on the build host. The BuildHost (VM) has the IP: 192.168.122.94, on its eth0 interface.
Steps
Make the repositories available on the buildhost-32
See if you are able to view the NFS share made available on the physical host.
[root@buildhost-32 ~]# showmount -e 192.168.122.1 Export list for 192.168.122.1: /data/cdimages 192.168.122.0/255.255.255.0
Create a mount point on the build host, and mount the NFS share on it.
[root@buildhost-32 ~]# mkdir /mnt/cdimages [root@buildhost-32 ~]# mount -t nfs 192.168.122.1:/data/cdimages/ /mnt/cdimages/ [root@buildhost-32 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 2.8G 913M 1.8G 34% / tmpfs 252M 0 252M 0% /dev/shm 192.168.122.1:/data/cdimages/ 191G 113G 69G 63% /mnt/cdimages [root@buildhost-32 ~]#
As you can see, the /data/cdimages from the physical host is now available on our buildhost-32, as /mnt/cdimages.
Create an empty directory CentOS-5.5-i386-tiny inside /mnt/cdimages, if not already done so. It must be empty though. This directory is going to hold our new custom distribution.
[root@buildhost-32 ~]# mkdir /mnt/cdimages/CentOS-5.5-i386-tiny
Copy the DVD structure, (excluding the CentOS directory), from /mnt/cdimages/CentOS-5.5-i386/ to this newly created directory /mnt/cdimages/CentOS-5.5-i386-tiny/.
[root@buildhost-32 ~]# rsync -av --exclude CentOS/ \ /mnt/cdimages/CentOS-5.5-i386/ /mnt/cdimages/CentOS-5.5-i386-tiny/
Without the CentOS directory, which holds all the RPMs of the distribution, the structure (with some necessary files), is about 226 MB in total.
[root@buildhost-32 ~]# du -sh /mnt/cdimages/CentOS-5.5-i386-tiny/ 226M /mnt/cdimages/CentOS-5.5-i386-tiny/ [root@buildhost-32 ~]#
I created a temporary directory named /tmp/rpms, and started copying RPM files one by one from the original source distribution directory (/mnt/cdimages/CentOS-5.5-i386/CentOS) , to this directory. I started with the kernel RPM and kept testing the installation of the RPMS I copied, in the /tmp/RPMtest directory, which is again, a freshly created empty directory.
[root@buildhost-32 tmp]# mkdir /tmp/rpms [root@buildhost-32 tmp]# mkdir /tmp/RPMtest
Copy one file at a time to the /tmp/rpms directory:
[root@buildhost-32 tmp]# cp /mnt/cdimages/CentOS-5.5-i386/CentOS/kernel-2.6.18-194.el5.i686.rpm \ /tmp/rpms/
Used the following two commands to test install the rpms I placed in /tmp/rpms/ directory.
rpm --initdb --dbpath /tmp/RPMtest/ rpm --test --dbpath /tmp/RPMtest/ -ivh /tmp/rpms/*.rpm
[root@buildhost-32 tmp]# rpm --test --dbpath /tmp/RPMtest/ -ivh /tmp/rpms/*.rpm warning: /tmp/rpms/kernel-2.6.18-194.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID e8562897 error: Failed dependencies: fileutils is needed by kernel-2.6.18-194.el5.i686 module-init-tools is needed by kernel-2.6.18-194.el5.i686 initscripts >= 8.11.1-1 is needed by kernel-2.6.18-194.el5.i686 mkinitrd >= 4.2.21-1 is needed by kernel-2.6.18-194.el5.i686 /bin/sh is needed by kernel-2.6.18-194.el5.i686 [root@buildhost-32 tmp]#
As you can see, now I need to copy more RPMs in the /tmp/rpms directory, to satisfy the dependencies problems seen above. This is a daunting manual task.
I created the following script, containing the same two lines to repeatedly test-install the RPMs.
[root@buildhost-32 tmp]# cat testrun.sh #!/bin/bash rpm --initdb --dbpath /tmp/RPMtest/ rpm --test --dbpath /tmp/RPMtest/ -ivh /tmp/rpms/*.rpm [root@buildhost-32 rpms]#
Note: During one of the test installations by the testrun.sh script (shown above), I got the following errors:
[root@buildhost tmp]# ./testrun.sh . . . . . . file /lib/libcrypto.so.0.9.8e conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /lib/libssl.so.0.9.8e conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /usr/bin/openssl conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /usr/lib/openssl/engines/lib4758cca.so conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /usr/lib/openssl/engines/libaep.so conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /usr/lib/openssl/engines/libatalla.so conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /usr/lib/openssl/engines/libchil.so conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /usr/lib/openssl/engines/libcswift.so conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /usr/lib/openssl/engines/libnuron.so conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /usr/lib/openssl/engines/libsureware.so conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686 file /usr/lib/openssl/engines/libubsec.so conflicts between attempted installs of openssl-0.9.8e-12.el5_4.6.i386 and openssl-0.9.8e-12.el5_4.6.i686
This happened because few RPMs (three in the list above), had both package.i386.rpm and package.i686.rpm files present in the same directories. Thus there was a conflict. So I pulled out the i686 rpms from the list:
[root@buildhost tmp]# mv rpms/*.i686* .
Checked the list of files pulled out, and found that there are three (3) .i686 files: glibc, openssl, and kernel.
[root@buildhost tmp]# ls *.rpm glibc-2.5-49.i686.rpm openssl-0.9.8e-12.el5_4.6.i686.rpm kernel-2.6.18-194.el5.i686.rpm
kernel does not have a corresponding i386 rpm file, so kernel needs to be back inside the rpms directory.
[root@buildhost tmp]# mv kernel-2.6.18-194.el5.i686.rpm rpms/
Re-ran the testrun.sh script to see if there are any conflicts anymore.
[root@buildhost tmp]# ./testrun.sh warning: /tmp/rpms/audit-libs-1.7.17-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897 Preparing... ########################################### [100%] [root@buildhost tmp]#
(No errors. Good!)
Please note that the most minimalistic list of packages, obtained by the process above, does not contain any servers. Even the ssh server is not there, so I added a couple of RPMs to this list. I added openssh-server, openssh-clients, wget, yum, vim-minimal, rootfiles, dhclient and grub (and their corresponding dependencies).
Once I have all the RPMs in the /tmp/rpms directory, and no more dependencies are required, I synced that (/tmp/rpms) to /mnt/cdimages/CentOS-5.5-i386-tiny/CentOS/ . (Need to create this directory, because we excluded this once we copied the base structure.)
[root@buildhost-32 tmp]# mkdir /mnt/cdimages/CentOS-5.5-i386-tiny/CentOS/ [root@buildhost-32 tmp]# rsync -av /tmp/rpms/ /mnt/cdimages/CentOS-5.5-i386-tiny/CentOS/
Complete list of RPMs
First, here are the basic stats of the list of RPMs I have:
Total number of packages, and their total size (un-installed):
[root@buildhost tmp]# ls /mnt/cdimages/CentOS-5.5-i386-tiny/CentOS/ | wc -l 111 [root@buildhost tmp]# du -sh /mnt/cdimages/CentOS-5.5-i386-tiny/CentOS/ 124M /mnt/cdimages/CentOS-5.5-i386-tiny/CentOS/
List of RPMs:
[root@buildhost tmp]# ls /mnt/cdimages/CentOS-5.5-i386-tiny/CentOS/ audit-libs-1.7.17-3.el5.i386.rpm basesystem-8.0-5.1.1.el5.centos.noarch.rpm bash-3.2-24.el5.i386.rpm binutils-2.17.50.0.6-14.el5.i386.rpm bzip2-libs-1.0.3-4.el5_2.i386.rpm centos-release-5-5.el5.centos.i386.rpm centos-release-notes-5.5-0.i386.rpm chkconfig-1.3.30.2-2.el5.i386.rpm coreutils-5.97-23.el5_4.2.i386.rpm cpio-2.6-23.el5_4.1.i386.rpm cracklib-2.8.9-3.3.i386.rpm cracklib-dicts-2.8.9-3.3.i386.rpm crontabs-1.10-8.noarch.rpm db4-4.3.29-10.el5.i386.rpm device-mapper-1.02.39-1.el5.i386.rpm device-mapper-event-1.02.39-1.el5.i386.rpm device-mapper-multipath-0.4.7-34.el5.i386.rpm diffutils-2.8.1-15.2.3.el5.i386.rpm dmraid-1.0.0.rc13-63.el5.i386.rpm dmraid-events-1.0.0.rc13-63.el5.i386.rpm e2fsprogs-1.39-23.el5.i386.rpm e2fsprogs-libs-1.39-23.el5.i386.rpm elfutils-libelf-0.137-3.el5.i386.rpm ethtool-6-4.el5.i386.rpm expat-1.95.8-8.3.el5_4.2.i386.rpm filesystem-2.4.0-3.el5.i386.rpm findutils-4.2.27-6.el5.i386.rpm fipscheck-1.2.0-1.el5.i386.rpm fipscheck-lib-1.2.0-1.el5.i386.rpm gawk-3.1.5-14.el5.i386.rpm gdbm-1.8.0-26.2.1.i386.rpm glib2-2.12.3-4.el5_3.1.i386.rpm glibc-2.5-49.i386.rpm glibc-common-2.5-49.i386.rpm grep-2.5.1-55.el5.i386.rpm grub-0.97-13.5.i386.rpm gzip-1.3.5-11.el5.centos.1.i386.rpm hmaccalc-0.9.6-3.el5.i386.rpm info-4.8-14.el5.i386.rpm initscripts-8.45.30-2.el5.centos.i386.rpm iproute-2.6.18-11.el5.i386.rpm iputils-20020927-46.el5.i386.rpm kernel-2.6.18-194.el5.i686.rpm keyutils-libs-1.2-1.el5.i386.rpm kpartx-0.4.7-34.el5.i386.rpm krb5-libs-1.6.1-36.el5_4.1.i386.rpm less-436-2.el5.i386.rpm libacl-2.2.39-6.el5.i386.rpm libattr-2.4.32-1.1.i386.rpm libcap-1.10-26.i386.rpm libgcc-4.1.2-48.el5.i386.rpm libselinux-1.33.4-5.5.el5.i386.rpm libsepol-1.15.2-3.el5.i386.rpm libstdc++-4.1.2-48.el5.i386.rpm libsysfs-2.0.0-6.i386.rpm libtermcap-2.0.8-46.1.i386.rpm libxml2-2.6.26-2.1.2.8.i386.rpm logrotate-3.7.4-9.i386.rpm lvm2-2.02.56-8.el5.i386.rpm m2crypto-0.16-6.el5.6.i386.rpm MAKEDEV-3.23-1.2.i386.rpm mcstrans-0.2.11-3.el5.i386.rpm mingetty-1.07-5.2.2.i386.rpm mkinitrd-5.1.19.6-61.i386.rpm mktemp-1.5-23.2.2.i386.rpm module-init-tools-3.3-0.pre3.1.60.el5.i386.rpm nash-5.1.19.6-61.i386.rpm ncurses-5.5-24.20060715.i386.rpm net-tools-1.60-81.el5.i386.rpm nspr-4.7.6-1.el5_4.i386.rpm nss-3.12.3.99.3-1.el5.centos.2.i386.rpm openssh-4.3p2-41.el5.i386.rpm openssh-clients-4.3p2-41.el5.i386.rpm openssh-server-4.3p2-41.el5.i386.rpm openssl-0.9.8e-12.el5_4.6.i386.rpm pam-0.99.6.2-6.el5_4.1.i386.rpm pcre-6.6-2.el5_1.7.i386.rpm popt-1.10.2.3-18.el5.i386.rpm procps-3.2.7-16.el5.i386.rpm psmisc-22.2-7.i386.rpm python-2.4.3-27.el5.i386.rpm python-elementtree-1.2.6-5.i386.rpm python-iniparse-0.2.3-4.el5.noarch.rpm python-sqlite-1.1.7-1.2.1.i386.rpm python-urlgrabber-3.1.0-5.el5.noarch.rpm readline-5.1-3.el5.i386.rpm redhat-logos-4.9.99-11.el5.centos.noarch.rpm rpm-4.4.2.3-18.el5.i386.rpm rpm-libs-4.4.2.3-18.el5.i386.rpm rpm-python-4.4.2.3-18.el5.i386.rpm sed-4.1.5-5.fc6.i386.rpm setup-2.5.58-7.el5.noarch.rpm sgpio-1.2.0_10-2.el5.i386.rpm shadow-utils-4.0.17-15.el5.i386.rpm sqlite-3.3.6-5.i386.rpm sysklogd-1.4.1-46.el5.i386.rpm SysVinit-2.86-15.el5.i386.rpm tar-1.15.1-30.el5.i386.rpm tcp_wrappers-7.6-40.7.el5.i386.rpm termcap-5.5-1.20060701.1.noarch.rpm tzdata-2010e-1.el5.noarch.rpm udev-095-14.21.el5.i386.rpm util-linux-2.13-0.52.el5_4.1.i386.rpm vim-minimal-7.0.109-6.el5.i386.rpm wget-1.11.4-2.el5_4.1.i386.rpm yum-3.2.22-26.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm zlib-1.2.3-3.i386.rpm [root@buildhost tmp]#
Few important points
When you install a server/pc with this distribution, you should note, that it can not query IP over DHCP, because it does not have dhclient RPM installed. Similarly the command prompt will be a simple "-bash-3.2#" . To change it, you may need to add rootfiles RPM to your distribution.
Install necessary packages on the buildhost-32
Once the RPM list is finalized, it is time to re-build the comps.xml file for it, and then build an ISO file out of it.
First, install the packages required to build the distribution, on the buildhost.
[root@buildhost-32 ~]# yum -y install anaconda anaconda-runtime mkisofs cdrecord
Edit and re-build the comps.xml file
The original comps.xml file is 11418 lines.
[root@buildhost-32 tmp]# wc -l /mnt/cdimages/CentOS-5.5-i386-tiny/repodata/comps.xml 11418 /mnt/cdimages/CentOS-5.5-i386-tiny/repodata/comps.xml
Most of it is "xml:lang" lines. Lets get rid of them, to create a (so called) language free file.
[root@buildhost-32 tmp]# grep -v "xml:lang" /mnt/cdimages/CentOS-5.5-i386-tiny/repodata/comps.xml > /tmp/no-lang.comps.xml [root@buildhost-32 tmp]# wc -l /tmp/no-lang.comps.xml 2607 /tmp/no-lang.comps.xml
After hand editing the file, and removing everything, which I did not need, here is the final version, comprising of only 58 lines in total. Notice that I changed the name of "core" to "tiny". This is the name of the group you will need to use in your kickstart.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE newcomps PUBLIC "-//CentOS//DTD Comps info//EN" "comps.dtd"> <comps> <group> <id>tiny</id> <name>Tiny</name> <description>Tiniest possible installation</description> <default>true</default> <uservisible>false</uservisible> <packagelist> <packagereq type="mandatory">SysVinit</packagereq> <packagereq type="mandatory">basesystem</packagereq> <packagereq type="mandatory">bash</packagereq> <packagereq type="mandatory">centos-release</packagereq> <packagereq type="mandatory">coreutils</packagereq> <packagereq type="mandatory">cpio</packagereq> <packagereq type="mandatory">e2fsprogs</packagereq> <packagereq type="mandatory">redhat-logos</packagereq> <packagereq type="mandatory">centos-release-notes</packagereq> <packagereq type="mandatory">filesystem</packagereq> <packagereq type="mandatory">glibc</packagereq> <packagereq type="mandatory">initscripts</packagereq> <packagereq type="mandatory">iproute</packagereq> <packagereq type="mandatory">iputils</packagereq> <packagereq type="mandatory">libgcc</packagereq> <packagereq type="mandatory">libtermcap</packagereq> <packagereq type="mandatory">mkinitrd</packagereq> <packagereq type="mandatory">procps</packagereq> <packagereq type="mandatory">readline</packagereq> <packagereq type="mandatory">rpm</packagereq> <packagereq type="mandatory">setup</packagereq> <packagereq type="mandatory">shadow-utils</packagereq> <packagereq type="mandatory">sysklogd</packagereq> <packagereq type="mandatory">termcap</packagereq> <packagereq type="mandatory">util-linux</packagereq> <packagereq type="mandatory">vim-minimal</packagereq> <packagereq type="default">grub</packagereq> <packagereq type="default">openssh-clients</packagereq> <packagereq type="default">openssh-server</packagereq> <packagereq type="default">yum</packagereq> <packagereq type="default">wget</packagereq> <packagereq type="default">dhclient</packagereq> <packagereq type="default">rootfiles</packagereq> </packagelist> </group> <category> <id>tiny-system</id> <name>Tiny System</name> <description>Tiniest pieces of the system.</description> <display_order>1</display_order> <grouplist> <groupid>tiny</groupid> </grouplist> </category> </comps>
Now remove all files from /mnt/cdimages/CentOS-5.5-i386-tiny/repodata . Then copy this no-lang.comps.xml file to that location.
[root@buildhost-32 tmp]# rm /mnt/cdimages/CentOS-5.5-i386-tiny/repodata/* -fr [root@buildhost-32 tmp]# cp /tmp/no-lang.comps.xml /mnt/cdimages/CentOS-5.5-i386-tiny/repodata/
Now rebuild the repodata:
[root@buildhost-32 tmp]# cd /mnt/cdimages/CentOS-5.5-i386-tiny/ [root@buildhost-32 CentOS-5.5-i386-tiny]# cat .discinfo 1272587247.016243 Final i386 1,2,3,4,5,6 CentOS/base /home/buildcentos/CENTOS/5.5/en/i386/CentOS CentOS/pixmaps [root@buildhost-32 CentOS-5.5-i386-tiny]# export discinfo=$(head -1 /mnt/cdimages/CentOS-5.5-i386-tiny/.discinfo) [root@buildhost-32 CentOS-5.5-i386-tiny]# echo $discinfo 1272587247.016243 [root@buildhost-32 CentOS-5.5-i386-tiny]# createrepo -u "media://$discinfo" -g repodata/comps.xml /mnt/cdimages/CentOS-5.5-i386-tiny/ 111/111 - CentOS/fipscheck-lib-1.2.0-1.el5.i386.rpm Saving Primary metadata Saving file lists metadata Saving other metadata [root@buildhost-32 CentOS-5.5-i386-tiny]#
Alhumdulillah. Repository created.