Custom Linux bootable CD

From WBITT's Cooker!

(Difference between revisions)
Jump to: navigation, search
(Required Packages on the build host)
Line 50: Line 50:
-
Off-the-topic: On Fedora, if you want to generate custom fedora spin-offs, you can use "revisor" . It has a wizard-like GUI interface.
+
Off-the-topic: On Fedora, if you want to generate custom fedora spin-offs, you can use "pungi" and "revisor" . It has a wizard-like GUI interface.
<pre>
<pre>
-
yum -y install revisor
+
yum -y install pungi revisor
</pre>
</pre>
-
 
===Build the install tree===
===Build the install tree===

Revision as of 16:14, 3 July 2010

This article is in relation to the article CENTOS Server CD project. It took few concepts from :

  1. http://people.redhat.com/rkeech/custom-distro.txt , which is now totally out-dated.
  2. http://greghaygood.com/2007/12/11/build-a-custom-centos-5-install-cd

In recent versions of RedHat and CentOS, most of the steps/commands shown in link #1 above, are now taken care by a single "createrepo" command. So here it goes.

Contents

First, the setup

Originally I tried to use my Fedora-11 machine (named kworkhorse), for doing all these steps of building the Custom CentOS cd. However, after burning two weeks of time, I realized that I have to build CentOS CD from a CentOS build host.

So what I did is, I simply created a small virtual machine, within my Fedora 11, which runs CentOS-5.4-x86_64. It is named "buildhost". I assigned 1GB of RAM and 3 GB of diskspace to this virtual machine. I did not use more space, because, I wanted to use least amount of disk space, and kind of re-use the already prepared "build-tree" from the Fedora11 machine. What I did was export /data/cdimages from Fedora11 host using NFS and mounted that on /mnt/cdimages on the newly CentOS VM.

The directory /data/cdimages, on my Fedora machine, contains full install tree of original CENTOS 5.4 64 bit CD in CENTOS-5.4-x86_64 subdirectory, and an empty CENTOS-5.4-x86_64-core (build) directory. When this directory is mounted on my buildhost, ove nfs, the directory layout looks like the following:

[root@buildhost cdimages]# pwd
/mnt/cdimages

[root@buildhost cdimages]# tree -d
.
├── CentOS-5.4-x86_64
│   ├── CentOS
│   ├── images
│   │   ├── pxeboot
│   │   └── xen
│   ├── isolinux
│   ├── NOTES
│   └── repodata
└── CentOS-5.4-x86_64-core

The directory /mnt/cdimages/CentOS-5.4-x86_64-core (which is empty at the moment), will be the custom install tree, and will be referred to as build-tree or build-directory in this document. Once again:

  • Machine on which CentOS CD is built: BuildHost
  • OS on build host: CentOS-5.4-x86_64
  • BuildDirectory: /mnt/cdimages/CentOS-5.4-x86_64-core

Required Packages on the build host

Before you continue, you must install the following packages on your base OS.

yum -y install anaconda anaconda-runtime mkisofs cdrecord

Note: anaconda-runtime is RHEL/CENTOS specific package, and is part of the RHEL/CENTOS distribution.


Off-the-topic: On Fedora, if you want to generate custom fedora spin-offs, you can use "pungi" and "revisor" . It has a wizard-like GUI interface.

yum -y install pungi revisor

Build the install tree

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

# rsync -av --exclude CentOS/  \ 
  /mnt/cdimages/CentOS-5.4-x86_64/  /mnt/cdimages/CentOS-5.4-x86_64-core/

Note: I prefer rsync, because it copies the .dot-files too. Later, we would be needing a special file named .discinfo, from the original tree.

When done, your buildtree would look like this:

[root@buildhost CentOS-5.4-x86_64-core]# pwd 
/mnt/cdimages/CentOS-5.4-x86_64-core

[root@buildhost CentOS-5.4-x86_64-core]# tree -d
.
├── images
│   ├── pxeboot
│   └── xen
├── isolinux
├── NOTES
└── repodata

6 directories
[root@buildhost CentOS-5.4-x86_64-core]# 

Now we need to copy selected RPMs from the source directory into the build directory. I created this file, by first creating a test VM using minimal kickstart, and noted the list of packages installed in it. I could not think of any easier way. The file is located in /tmp/minivm, as "installed-rpms.txt" . (Look in CENTOS Server CD project to see how I generated it. Or use the Core Packages List CentOS-5.4-x86 64 list for list of packages required for CentOS 5.4 64 bit.)

# mkdir /mnt/cdimages/CentOS-5.4-x86_64-core/CentOS/

# for filename in $(cat /tmp/minivm/installed-rpms.txt); do 
  cp -v /mnt/cdimages/CentOS-5.4-x86_64/CentOS/"${filename}.rpm" \ 
    /mnt/cdimages/CentOS-5.4-x86_64-core/CentOS/ 
done

Make sure you copy kernel-* files to the build tree. This is important, because at times, you may be using this CD in all sorts install scenarios, such as installation of bare-metal hosts, KVM hosts, XEN hosts, etc. So you would need at least two types of kernels in your installation.

comps.xml

From the original howto: Comps file. The file $RHROOT/RedHat/base/comps.xml defines the set of packages known to the installer. The set of packages described in comps.xml must be reduced to only those required. It is not necessary to remove the unused package files from $RHROOT/RedHat/RPMS/. Some packages from $RHROOT/RedHat/RPMS/ are necessary in the process of building the install CD even though they might be excluded from the custom build.

Here is an example comps.xml file from the original howto (RHEL3 based).

As I mentioned in the related article, (borrowing the sentence/term from another author), "the comps.xml has gazillion languages represented in it". I want to at least get rid of the languages stuff from the file, so I can work on it.

Here is something interesting. The original comps.xml file (CentOS-5.4) is 11418 lines.

[root@buildhost CentOS-5.4-x86_64-core]# wc -l repodata/comps.xml 
11418 repodata/comps.xml
[root@buildhost CentOS-5.4-x86_64-core]#

Interestingly, there are 8811 "xml:lang" lines in it!

[root@buildhost CentOS-5.4-x86_64-core]# grep  "xml:lang" repodata/comps.xml | wc -l
8811

The "xml:lang" lines look like this and repeat themselves a lot!

    <name xml:lang="nl">Cluster-opslag</name>
. . . 
    <description xml:lang="nl">Pakketten die ondersteuning bieden voor cluster-opslag.</description>

Lets create a "language-free" version of this file.

[root@buildhost CentOS-5.4-x86_64-core]# grep -v  "xml:lang" repodata/comps.xml > /tmp/no-lang.comps.xml

[root@buildhost CentOS-5.4-x86_64-core]# wc -l /tmp/no-lang.comps.xml 
2607 /tmp/no-lang.comps.xml

As you can see, only 2607 lines to edit! Great! It's time to edit this file, remove anything which is not related to us, and replace the repodata/comps.xml file with the new one.

Here is the (80 lines) file I ended with: Comps.xml for CentOS-5.4-x86 64 minimal install !!!

Now remove all files in repodata/* and copy your newly created file to repodata, as comps.xml .

[root@buildhost CentOS-5.4-x86_64-core]# pwd
/mnt/cdimages/CentOS-5.4-x86_64-core

[root@buildhost CentOS-5.4-x86_64-core]# rm repodata/* -f

[root@buildhost CentOS-5.4-x86_64-core]# cp /tmp/no-lang.comps.xml  repodata/comps.xml

Building the stuff

The RHEL3 based howto recommends to run the commands pkgorder, buildinstall, etc, on the build tree. This is no longer valid. A simple createrepo command takes care of everything.

Personal tools