CENTOS Server CD project

From WBITT's Cooker!

Revision as of 23:40, 24 June 2010 by Kamran (Talk | contribs)
Jump to: navigation, search

Contents

Why Server CD?

Lately I thought of installing a XEN CENTOS 5.5 virtual machine on one of my servers out there. I needed the exploded tree of the ISO to be available. However, when I checked centos.org website, I noticed that they stopped distributing a "Single Server CD" after CENTOS 4. I could have downloaded a CENTOS 5.5 DVD image on the server but it was kind of un-desired / not practical for two reasons.

  • The centos.org distributes DVD iso image through bit-torrent, and my server service provider does not allow P2P or torrent traffic.
  • Even if I had one, I would have to download one big 4-5 GB file to my server. Whereas a few hundred MBs would do, if I want a text based "core" installation only.

So there arose an itch, and I decided to create a project to scratch that itch!

Objectives / Project goals

  • To create a repository / collection of files, a so called "Server CD" install-tree, small enough to provide the "core" installation, plus yum and wget.
  • To be able to create a boot-able /installable "install CD" out of the install-tree mentioned above. So that, when I (or anyone else) need to install a minimum OS on a bare-metal machine, he doesn't have to go through downloading a full DVD.

Creating the exploded tree repository, the hard way

The idea is simple. I have a CENTOS 5.4 DVD already downloaded at home (and office). To get the list of packages, I did a "core" install of CENTOS on a XEN virtual machine. (I used a kickstart file with @core mentioned in the "%packages" section. Analysing its "/root/install.log", I quickly figured out which packages got installed. (clever me!). So this is the list of packages I need from the "CentOS" directory of the install-tree. (It's about 443 packages). This resulted in an installation of about 950MB in size.

Here is how I used (install.log) to generate the list of required pacakges in my repository.

[root@xenlab minivm]# grep "Installing" install.log | awk '{print $2}'|sort > installed-rpms.tmp

Then I edited the resulting file to remove strange numbers before the package names, such as:

basesystem-8.0-5.1.1.el5.centos.noarch
cracklib-dicts-2.8.9-3.3.x86_64
1:termcap-5.5-1.20060701.1.noarch          <<<<------- Such as this one. What is this number ?
nash-5.1.19.6-54.x86_64


This is good enough. However, I am too much irritated by seeing bluetooth, cups, x11, and similar packages being part of the core installation. So I went one step further, and started deleting packages using yum, in a polite fashion, from this VM. This way, I was able to delete some packages, which I consider un-necessary for an installation, where only a web-server is the only desired service to run, without any backend database. (Which was the case with me.). After this surgery, I was able to bring down the disk usage to about 750 MB. And of-course, fewer number of packages. (About 118 less rpms!). I can use that in the %post to delete the un-necessary RPMs!

# yum remove aspell aspell-en atk authconfig autofs avahi avahi-compat-libdns_sd \ 
  bitstream-vera-fonts bluez-gnome bluez-libs bluez-utils cairo ccid coolkey \ 
  cpuspeed crash cups cups-libs desktop-file-utils dhcpv6-client dnsmasq \ 
  dos2unix dosfstools ecryptfs-utilsed eject fbset finger firstboot-tui \ 
  fontconfig freetype GConf2 gpm gtk2 hicolor-icon-theme htmlview ifd-egate \ 
  iptables-ipv6 irda-utils irqbalance jwhois krb5-workstation ksh libdrm  \
  libICE libjpeg libnotify libpng libSM libtiff libwnck libX11 libXaulibXcursor \ 
  libXdmcp libXext libXfixes libXft libXi libXinerama libXrandr libXrender \ 
  libXres libXt libXxf86vm mailcap man man-pages mdadm mesa-libGL microcode_ctl \
  mkbootdisk mtools nano NetworkManager NetworkManager-glib newt \
  notification-daemon ntsysv numactl ORBit2 pam_ccreds pam_krb5 pam_pkcs11 \ 
  pam_smb pango paps pcmciautils pcsc-lite pcsc-lite-libs pinfo procmail rdate \ 
  redhat-lsb redhat-menus rhpl rp-pppoe rsh sendmail setuptool slang sos \ 
  specspo startup-notification syslinux system-config-network-tui \
  system-config-securitylevel-tui tcpdump trousers unix2dos vconfig \ 
  wireless-tools words wpa_supplicant xorg-x11-filesystem ypbind \ 
  yp-tools yum-updatesd

Tip: I used the following commands to generate the long yum command above:

# grep Erased /var/log/yum.log | awk '{ print $5}' | sort | uniq | tr '\n' ' '


To create my minimal repository, I first created a copy of the original install tree skipping the CentOS directory.

[root@xenlab ~]# rsync -av --exclude CentOS/  \ 
  /var/www/html/CentOS-5.4-x86_64/  /var/www/html/CentOS-5.4-x86_64-core/

Then I used the list of packages from the install.log file, and pulled the matching RPM files from the full install-tree into this "core" install-tree. I used the "installed-rpms.txt" file, I created a moment ago, above. The installed-rpms.txt file looks like this:

[root@xenlab ~]# cat /tmp/minivm/installed-rpms.tmp | tail
which-2.16-7.x86_64
words-3.0-9.1.noarch
xorg-x11-filesystem-7.1-2.fc6.noarch
yp-tools-2.9-0.1.x86_64
yum-3.2.22-20.el5.centos.noarch
yum-fastestmirror-1.1.16-13.el5.centos.noarch
yum-metadata-parser-1.1.2-3.el5.centos.x86_64
zip-2.31-2.el5.x86_64
zlib-1.2.3-3.i386
zlib-1.2.3-3.x86_64
[root@xenlab ~]#

Create the CentOS directory in the "core" install tree:

[root@xenlab ~]# mkdir /var/www/html/CentOS-5.4-x86_64-core/CentOS

Then copy the selected files from the full install-tree into this "core" tree, using the installed-rpms.txt file.



[root@xenlab ~]# for file in $(cat /tmp/minivm/installed-rpms.tmp); do 
  cp -v /var/www/html/CentOS-5.4-x86_64/CentOS/"${file}.rpm" \ 
    /var/www/html/CentOS-5.4-x86_64-core/CentOS-5.4-x86_64-core/CentOS/ 
done 

Check the "core" CentOS directory:

[root@xenlab ~]# cd /var/www/html/CentOS-5.4-x86_64-core/CentOS/

[root@xenlab CentOS]# ls -l | wc -l
443

[root@xenlab CentOS]# du -sh .
273M    .
[root@xenlab CentOS]# 

Lovely! As you can see only 443 RPMs and 273 MB occupied by the RPMs only!


When I was done with doing so, I created another XEN VM, and used this new (shrunk) install-tree to install the new VM to make sure it works. And it did!

Now, to use this install tree on my server on the internet, I can do one of the following:

  • Push the repository tarball to my XEN physical host/server on internet,
  • Or, make a script to "wget" all the required packages from a CENTOS mirror, create a repo for the installer, and make that available through yum on that server.

The first method is kind of immediately do-able, but not "exciting". It definitely involves copying all the install tree to the XEN host up there. To do the second method, I created a kind of script, which can pull the packages from any install tree on the internet and populate the CentOS directory on my own install-tree. Good enough, but still not geeky enough.

What I want to do now, is to be able to parse comps.xml file, present in the repodata directory of any regular install tree, find out the packages needed for "@core" and then pull those packages from the regular install tree into my own install tree. (This would be geeky/cool.)

And when I can do that, I can then create an actual bootable ISO out of it using help from many posts on the internet (mentioned at the end of this document).

Packages which can be removed from @core

Here is the list of packages which I found in CENTOS-5.4-x86_64, which I was successfully able to remove, using yum, without any damage to the OS. (about 118 packages)

aspell
aspell-en
atk
authconfig
autofs
avahi
avahi-compat-libdns_sd
bitstream-vera-fonts
bluez-gnome
bluez-libs
bluez-utils
cairo
ccid
coolkey
cpuspeed
crash
cups
cups-libs
desktop-file-utils
dhcpv6-client
dnsmasq
dos2unix
dosfstools
ecryptfs-utils
ed
eject
fbset
finger
firstboot-tui
fontconfig
freetype
GConf2
gpm
gtk2
hicolor-icon-theme
htmlview
ifd-egate
iptables-ipv6
irda-utils
irqbalance
jwhois
krb5-workstation
ksh
libdrm
libICE
libjpeg
libnotify
libpng
libSM
libtiff
libwnck
libX11
libXau
libXcursor
libXdmcp
libXext
libXfixes
libXft
libXi
libXinerama
libXrandr
libXrender
libXres
libXt
libXxf86vm
mailcap
man
man-pages
mdadm
mesa-libGL
microcode_ctl
mkbootdisk
mtools
nano
NetworkManager
NetworkManager-glib
newt
notification-daemon
ntsysv
numactl
ORBit2
pam_ccreds
pam_krb5
pam_pkcs11
pam_smb
pango
paps
pcmciautils
pcsc-lite
pcsc-lite-libs
pinfo
procmail
rdate
redhat-lsb
redhat-menus
rhpl
rp-pppoe
rsh
sendmail
setuptool
slang
sos
specspo
startup-notification
syslinux
system-config-network-tui
system-config-securitylevel-tui
tcpdump
trousers
unix2dos
vconfig
wireless-tools
words
wpa_supplicant
xorg-x11-filesystem
ypbind
yp-tools
yum-updatesd

References/Further Reading

Some smart people have already done this. Below are some links for reference:

Personal tools