Very minimal CentOS image howto

I’ve seen it said by someone at Redhat, “The favorite whipping boy around here is anaconda. Every slow or failed install is anaconda’s fault. Never mind that someone here wrote it,” and I agree. I don’t like the anaconda installs, I think even the minimum install is bloated for a minimalist VM approach, so here’s how I like to make my minimal CentOS install.

First, download the current centos-release and centos-release-notes for your architecture from your favorite mirror. I’m doing this with Fedora 13, adjust for your favorite flavor.

su -

Next, let’s create a work directory to do this under. I have lots of space in my home directory, so I’m going to use that:

mkdir -p ${WKDIR}/image
cd ${WKDIR}

We’re going to use yum to do our install, so we’re going to create a custom yum config:

cat >yum.conf <<EOF

We initialize the rpm database and install the centos-release rpms:

rpm -r ${WKDIR}/image --initdb
rpm -ivh --nodeps -r ${WKDIR}/image centos-release*rpm

Now we just install the yum and rpm using yum:

yum -c yum.conf --nogpgcheck install rpm yum

I’m sure there’s some way to leave gpgcheck enabled, but I haven’t looked for it. If someone wants to figure that out and let me know, I’ll update my article.

Since we created the rpm database using our parent OS, it may not be using the correct db version, so let’s recreate it using the tools we just installed. We’re going to reinstall using these tools, so we’ll need the rpms we downloaded earlier as well.

cp centos-release*rpm ${WKDIR}/image/root
cp /etc/resolv.conf ${WKDIR}/image/etc/
mount -t proc none ${WKDIR}/image/proc
chroot ${WKDIR}/image
rm -rf /var/lib/rpm/*
rpm --initdb
rpm -ivh --nodeps ~/centos-release*rpm
yum -y groupinstall Base
yum clean all

So now we have a fairly minimalist centos tree (397 packages) weighing in at about 820 Mb. You can install other packages now, set up some initial configurations, etc.

You could have an even slimmer install if you wanted to be more selective. I find the Base group to be sufficiently slim for most cases.

If you’re using pxe for nfs rooted VMs, then your image is done. Move the image where you want it, export it and see the next article about nfs rooted vm’s.

If you need a bootable grub image for a stand-alone vm, ask me and if I get enough requests I’ll write about how to do that too.


~ by edwyseguru on October 7, 2010.

One Response to “Very minimal CentOS image howto”

  1. Very interesting. I’d be interested to know your approach to creating a bootable grub image.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: