ORC Owl Logo 2  

Owl River Company

 
  Your IP is: 54.237.235.12

Building a tiny CentOS installation

25 Aug 2008: Standalone script posted
Enough people has asked about updating this page, that I carved out the script, so local self-testing cam be done. Please get it from: ftp://ftp.owlriver.com/pub/local/COLUG/tiny-centos.sh

A recurring question with the emergence of Red Hat's Enterprise product, and the rebuild efforts is: How can I make the darn thing smaller?

We do not quite understand this -- part of the allure of a 'enterprise' grade operating system is stability and maintainability; size is not a design goal or requirement.

But that said, and because the of the ongoing questions, we sat down to develop and document a kickstart configuration file and script, to work generally for any anaconda installation mediated host, for this goal state -- This ks.cfg is suitable for doing such 'tiny' installations. It is of the customary type ks.cfg file, with some 'special sauce' in the %post stanza, to strip out undesired packages.

The design criteria in deciding if a given package was necesssary, was: May it be removed without violating a dependency requirement? The code performs this test repeatedly until no additional single package may be removed.

With that effort, we get a CentOS 4[.0] install down to 349 Meg. Six months after the initial release of this document, we added detail for a fully updated CentOS 4.2 system. As of 27 October 2005, such an install weighs in at 376 Meg. (376,024). The first figure in the 4.2 listing was pre-update; the second, post.

Revisiting this again for CentOS 4.4 [note that in CentOS, these 'point' releases are all the '4' series release, with the Update level respin indicated to the right of the 'dot'] in October 2006, we cut to the chase in our methodology, as we have done this a couple times before, as descibed elsewhere in this piece. Anyway, we went ahead and did the update and pulled out the obsoleted kernel. We also pull out the gratuitous Infiniband cruft and helper packages:
[root@dhcp-239 ~]# rpm -e kernel-ib-1.0-1 dapl librdmacm libibverbs \ libsdp libmthca [root@dhcp-239 ~]#
Other stuff that we do not want has snuck its way in as well -- we have long had a minimal helper script ORCpiggy, which returns a listing of the size, and name of each packages in a numerically ascending by size sorted fashion. It identified some more targets. We can test a bit, and squeeze some water out of this install, with any luck:
[root@dhcp-239 ~]# ORCpiggy |tac ... 4501374 pam 4584342 net-snmp-libs 4657535 ncurses 4997528 words 5016049 lvm2 5046857 groff 5112634 bash 6674380 binutils 7308841 coreutils 8113529 redhat-logos 12406965 glibc 20486843 python 28581969 kernel 31738315 comps 32713959 perl 59306351 glibc-common ======================================== PUID: [root@dhcp-239 ~]# rpm -e rhnlibcomps redhat-logos net-snmp-libs error: Failed dependencies: system-logos is needed by (installed) grub-0.95-3.5.i386 libnetsnmp.so.5 is needed by (installed) OpenIPMI-1.4.14-1.4E.13.i386 [root@dhcp-239 ~]#
darn it ... we may safely dump rhnlib, (as CentOS uses yum), but not those fat logos; we know from experience that there are OpenIPMI-libs that are in the braindead base install, as well, to deal with. We decide to leave man-pages
[root@dhcp-239 ~]# rpm -e rhnlib comps net-snmp-libs OpenIPMI OpenIPMI-libs [root@dhcp-239 ~]# ORCpiggy |tac | grep doc [root@dhcp-239 ~]#
As of October 2006, (CentOS 4.4) our install weighs in at a really unpleasantly hefty 549 Meg. (549,964) nominal as to inodes space used, 471,144 actual byte count.
[root@dhcp-239 /]# export LANG=C ; du --one-file-system / | sort -n | \ tail -3 239248 /usr/lib 454604 /usr 551596 / [root@dhcp-239 /]#

We have not considered duplex and N-plex removals (although we know such opportunities exist -- we consider this 'small enough'), and leave a working sshd, and such on the host, for maintenance purposes.


We post a flat listing of the ks.cfg used below. It may be used (and indeed, we do use it to produce this report), as documented in our PXE installation outline with a stanza like this in /tftpboot/rhl/pxe/pxelinux.cfg/:

# cat /tftpboot/rhl/pxe/pxelinux.cfg/default 
default linux 
serial 0,38400n8
label linux 
  kernel vmlinuz 
  append ksdevice=eth0 load_ramdisk=1 prompt_ramdisk=0 \
  ramdisk_size=16384 initrd=initrd.img network \
  ks=http://www.owlriver.com/tips/tiny-centos/ks.cfg-tiny.txt
(Note: We use the conventional 'backslash continuation' convention here for typographical clarity of presentation. Please be aware that it is NOT presently supported in syslinux booting.)

Please report any errors, unclarity, or suggestions for improvement to: info+tiny@owlriver.com . Please confirm that you are viewing the most recent copy of this site, and mention the revision date below.

-- Russ Herrold

Appendix:
# Kickstart file 
#
#       Centos_40 minimal -- by RPH 050311
#		info@owlriver.com
#	ORCsetPXE Centos_40
#
install
lang en_US.UTF-8
langsupport --default en_US.UTF-8 en_US.UTF-8
keyboard us
mouse generic3ps/2 --device psaux
skipx
network --device eth0 --bootproto dhcp
# 
url --url ftp://ftp/pub/install/ftpinstall/
rootpw --iscrypted $1$UwybGRX3$sRRuchanged566s125qok/
firewall --disabled
authconfig --enableshadow --enablemd5
timezone America/New_York
bootloader --location=mbr --append hdb=ide-scsi
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart 	--all --drives=hda
part / 		--fstype ext3 --size=800  --ondisk=hda
part swap 	              --size=384  --ondisk=hda --maxsize=768 

%packages
sudo
kernel
grub
openssh-server
openssh
openssh-clients
joe
yum
#
-anacron
-apmd
-autofs
-bluez-libs
-bluez-bluefw
-bluez-hcidump
-bluez-utils
-comps
-cups
-cups-libs
-desktop-file-utils
-dhcpv6_client
-diskdumputils
-dmraid
-eject
-finger
-lftp
-logwatch
-rpmdb-CentOS
-fbset
-freetype
-fontconfig
-htmlview
-ipsec-tools
-iptables
-irda-utils
-isdn4k-utils
-lockdev
-mailcap
-mdadm
-mgetty
-minicom
-mt-st
-nano
-nc
-netdump
-nfs-utils
-quota
-pcmcia-cs
-pinfo
-portmap
-rdist
-rmt
-rp-pppoe
-rsh
-statserial
-setserial
-slocate
-specspo
-stunnel
-sysreport
-system-config-securitylevel-tui
-system-config-network-tui
-talk
-tcpdump
-up2date
-vconfig
-wvdial
-wireless-tools
-ypbind
-yp-tools
#
-redhat-lsb
-xorg-x11-Mesa-libGL
-xorg-x11-libs
#
#	needed to quell install noise
system-config-mouse
#
-pyxf86config
-rhpl
#
-libwvstreams
-ppp
#
-utemper
-wireless-tools
#
%post
#
#
#	get syslog working so we can see what is happening
echo "*.*  @10.16.1.253 " >> /etc/syslog.conf
/sbin/service syslog restart > /dev/null 2>&1
echo "syslog started " | logger -p local1.info
sleep 5
#
#
#	Set up a local archive of the complete install set
#	for later maintenance (local only)
#
rpm --import `find /usr/share/doc -name '*GPG*' | grep -v -i centos | \
	head -1` 2> /dev/null
rpm --import `find /usr/share/doc -name '*GPG*' | grep -i centos | \
	head -1` 2> /dev/null
#
# rpm --import `find /usr/share/doc -name '*GPG*' | grep -v orc | \
# 	head -1` 2> /dev/null
#
#	Free up the yum cached files
yum -y clean all
#
#	remove some obvious dupes
for i in kernel kernel-smp ; do
	NONCE=`rpm -q $i 2> /dev/null | wc -l | awk '{print $1}'`
	export CNT=`echo " 0${NONCE} + 0" | bc`
#
echo "cnt: $CNT pre while $NONCE " | logger -p local1.info
sleep 5
#
	while [ $CNT -gt 1 ] ; do
		NONCE=`rpm -q $i --last | awk '{print $1}' | tail -1`
#
echo "kernel: $NONCE " | logger -p local1.info
sleep 5
#
		rpm -e $NONCE  && echo "  removed extra $NONCE kernel" | \
			 logger -p local1.info
		NONCE=`rpm -q $i 2> /dev/null | wc -l | awk '{print $1}'`
		export CNT=`echo " 0${NONCE} + 0" | bc`
#
echo "cnt: $CNT in while $NONCE " | logger -p local1.info
sleep 5
#
	done
done
#
#
DIRTY="1"
while [ "x$DIRTY" = "x1" ] ; do
export DIRTY="0"
echo "restarting ... " | logger -p local1.info
#
#	anaconda wants bc
for i in `rpm -qa --qf '%{name}\n' | grep -v joe | grep -v ssh | \
	grep -v rsync | grep -v dhclient | grep -v mouse | \
	grep -v sel | grep -v policy | grep -v nscd | \
	grep -v kernel | grep -v dos | grep -v ^bc | \
	grep -v grub | grep -v yum `; do
	echo "testing $i" | logger -p local1.info
	[ "x$i" != "x" ] && rpm -e $i 2> /dev/null && {
		echo "   removed $i" | logger -p local1.info
		export DIRTY="1"
		}
done
done
echo "done ... " | logger -p local1.info
#
###########################################################
#
#



df 
==============================

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda1               806368    349520    415884  46% /
none                     62612         0     62612   0% /dev/shm


du | sort -n | tail -11  
==============================

28816	./lib/modules/2.6.9-5.0.3.EL
28832	./lib/modules
34108	./usr/lib/python2.3
34720	./usr/lib/perl5/5.8.5
35488	./usr/lib/perl5
39564	./lib
95688	./usr/lib/locale
111420	./usr/share
130138	./proc
198376	./usr/lib
326368	./usr
525810	.


rpm -qa -qf '%{name}\n' | sort 
==============================

aspell
aspell-en
basesystem
bash
bc
beecrypt
binutils
bzip2-libs
centos-release
centos-yumconf
checkpolicy
chkconfig
coreutils
cpio
cracklib
cracklib-dicts
cyrus-sasl
cyrus-sasl-md5
db4
dbus
dbus-glib
device-mapper
dhclient
diffutils
dos2unix
dosfstools
e2fsprogs
elfutils
elfutils-libelf
ethtool
expat
filesystem
findutils
gawk
gdbm
glib2
glibc
glibc-common
gmp
gpg-pubkey
gpg-pubkey
grep
grub
gzip
hal
hotplug
hwdata
info
initscripts
iproute
iputils
joe
kernel
kernel-utils
krb5-libs
kudzu
less
libacl
libattr
libcap
libgcc
libselinux
libsepol
libstdc++
libtermcap
libuser
libxml2
libxml2-python
lvm2
MAKEDEV
mingetty
mkinitrd
mktemp
module-init-tools
ncurses
net-tools
newt
nscd
openldap
openssh
openssh-clients
openssh-server
openssl
pam
passwd
pcre
perl
perl-Filter
policycoreutils
popt
procps
psmisc
python
pyxf86config
readline
redhat-logos
rhpl
rpm
rpm-libs
rpm-python
rsync
sed
selinux-policy-targeted
setup
shadow-utils
slang
sysklogd
system-config-mouse
SysVinit
tar
tcp_wrappers
termcap
tzdata
udev
unix2dos
usbutils
usermode
util-linux
yum
zlib
Up More Tips

Building a tiny CentOS installation


   http://www.owlriver.com/tips/tiny-centos/


We make this available for non-commercial and individual use. Please respect our copyright, and consider contacting us for all your Open Source and *nix design, architect / systems analysis, and administration needs.


Copyright (C) 2005 R P Herrold
      herrold@owlriver.com  NIC: RPH5 (US)
   My words are not deathless prose,
      but they are mine.

       Owl River Company
   "The World is Open to Linux (tm)"
   ... Open Source LINUX solutions ...
      info@owlriver.com
         Columbus, OH

rev 051027 RPH
http://www.owlriver.com/tips/tiny-centos/


See also:
    PXE installation outline

Up More Tips