In December 2006, the Fedora Linux distribution released its first official Live CD, which, thanks to an intelligent selection of applications, nicely advertises the best features of Fedora. In addition to many applications, the Live CD has several games, uses the Compiz 3D desktop, and is accessible by non-English speaking users. But what stole the show for me was David Zeuthen's livecd tools, which make creating and maintaining a custom Fedora-based Live CD a walk in the park.
Zeuthen is the developer of Pilgrim, which creates system images that can run off USB flash drives for the One Laptop Per Child project (OLPC; see Resources for a link to more information). The livecd tools used for creating the Fedora Live CD is a rewrite of Pilgrim in Python. It can be used for creating live CDs out of Red Hat Enterprise Linux, CentOS, and other downstream Fedora distributions.
Before getting down to making your own Live CD, you need to understand how a Fedora release is assembled, distributed, and maintained. The Fedora project keeps packages in two publicly accessible repositories. The repository maintained by official Fedora developers is called the "core" repository, while the one maintained by contributors and the community is called the "extras" repository. A repository is simply a collection of packages. Apart from the core and extras, there are several third-party repositories such as Livna and FreshRPM.
A Fedora Core distribution contains all the packages in the core repository, the latest being Fedora Core 6. The first official Fedora Live CD is based on packages in Fedora Core 6 and the extras repository. The livecd tools have been submitted for inclusion in Fedora's extras repository, which will be merged with the core repository by the time Fedora 7 is released.
The biggest advantage of the livecd tools approach to creating Live CDs is the design that separates the tools from the Live CD. To cook a Live CD, all you need is a set of configuration files. These configuration files contain a list of packages that you need on the Live CD and also describe the type of system configuration that will happen once the Live CD is booted.
To assist the custom Live CD maintainer, these configuration files are packaged as RPMs and kept in a repository of their own. As the Fedora distribution and its repositories move from version to version, you can keep updating these configuration files to pull the relevant packages.
Zeuthen has made available three such RPMs that you can base your custom Live CDs on. These RPMs follow an inheritance scheme that assists in creating derivative versions. The fedora-livecd package is a minimal Live CD with no user interface. The fedora-livecd-gnome package is based on the fedora-base package and includes a GNOME desktop. The fedora-livecd-desktop packages builds on top of the fedora-gnome package and gives a GNOME desktop with lots of applications and other things.
Figure 1, from Zeuthen, explains this better.
Figure 1. Relationship among livecd tools packages
Zeuthen also suggests that in the future it might also help other official Fedora Special Interest Groups (SIGs) to roll their own distributions derived from these RPMs.
Figure 2. Possible organization of derivative packages
This might sound a little obscure, but once you get your hands dirty, you'll appreciate this approach.
The first step is to get the livecd-tools RPM that is available from Zeuthen's Fedora home page. Just grab and install the livecd-tools-001-1.i386.rpm like so:
Listing 1. Installing the Live CD tools
$ su - <Enter root password> # wget -c http://people.redhat.com/davidz/livecd/i386/livecd-tools-001-1.i386.rpm # rpm -ivh livecd-tools-001-1.i386.rpm
You should now have the
livecd-creator command, which
you can invoke without any options to get a simple list of commands.
Listing 2. Options provided by the livecd-creator command
$ livecd-creator No packages specified. usage: livecd-creator [--help] [--repo=<name1>,<url1> ...] [--repo=<name2>,<url2>] --package=<p1> [--package=<p2> ...] [--exclude-package=<e1>] --exclude-package=<e2> ...] [--base-on=<path-to-iso-file>] [--fslabel=<label>] --help : Print usage and exit --repo : Path to yum repository --package : Include this package --exclude-package : Exclude this package --base-on : Add packages to an existing live CD iso9660 image --fslabel : File system label (default: livecd-YYYYMMDD-HHMI)
You also need to have access to RPMs of the tools that you want on your custom
Live CD. If you are on a fast Internet connection,
livecd-creator can download them and the packages they depend upon
before creating the Live CD. The other option is to copy all the packages from
Fedora Core 6 installation CDs or DVD and create a local "core" repository. To
create a local repository, you'll need the createrepo tool.
Listing 3. Installing the createrepo tool
# wget -c http://tqmcube.com/files/createrepo-0.4.3-5.1.noarch.rpm # rpm -ivh createrepo-0.4.3-5.1.noarch.rpm
Now, create the local repository by first copying all the RPMS from Core 6's five CDs or single DVD and then using the createrepo tool.
Listing 4. Creating a local repository
# mkdir /var/www/html/repo/core/ # cp <PATH TO RPMs> /var/www/html/repo/core/ # createrepo /var/www/html/repo/core/
This last command will take some time to complete and will create a repodata
livecd-creator command uses this
directory to get to the packages.
Since you'll be using Zeuthen's packages to base your Live CD on, you'll need to create a local repository for them as well.
Listing 5. Creating a repository of the LiveCD packages
# mkdir base_packages # cd base_packages # wget -c http://people.redhat.com/davidz/livecd/i386/fedora-livecd-6-1.i386.rpm # wget -c http://people.redhat.com/davidz/livecd/i386/fedora-livecd-gnome-6-1.i386.rpm # wget -c http://people.redhat.com/davidz/livecd/i386/fedora-livecd-desktop-6-1.i386.rpm # createrepo /root/base_packages
As before, this last command will produce the repodata directory to help
livecd-creator locate the configuration packages.
Now that you have your repositories set, you can easily create custom Live CDs.
livecd-creator command produces ISO images that can
be burned to CD-Rs. But I'd recommend using virtualization software to test the
ISO without actually burning them onto physical media. There are several freely
available, such as VMware Player, QEMU, and VirtualBox.
To get the hang of the
livecd-creator command, begin
by creating a minimal Live CD:
Listing 6. Creating a minimal Live CD
# livecd-creator --repo=c6,file:///var/www/html/repo/core --package=bash \ --package=kernel --package=grub --fslabel=Fedora-minimal-LiveCD
This command asks
livecd-creator to grab three
packages -- bash, grub, and the kernel -- from the local repository and include
them in a Live CD called Fedora-minimal-LiveCD. The
livecd-creator command uses Fedora's YUM to install these packages and
will thus also install other applications that the specified packages depend upon.
The command will take some time to complete, since it will create a working space, then install the specified packages and their dependencies, relabel the working space for SELinux, Fedora's security mechanism, compress the whole working space, configure the Live CD bootloader, GRUB, and finally create the ISO image.
Congratulations! You've just created your first Live CD. Of course, you'll not be able do much with it, since it lacks the configuration files.
Now that you know how the
works, you can use it to create a Live CD that includes GNOME.
Listing 7. Creating a Live CD with GNOME
# livecd-creator --repo=c6,file:///var/www/html/repo/core \ --repo=lcd6,file:///root/base_packages \ --package=fedora-livecd-gnome \ --repo=e6,http://download.fedora.redhat.com/pub/fedora/linux/extras/6/i386 \ --fslabel=My-Fedora-LiveCD-1
Here, you use the local repository for base packages and specify which configuration package you need to base your CD on. You also specify that any package that is required by fedora-livecd-gnome should be fetched from your local core repository. There are some packages in fedora-livecd-gnome that are not in the core repository. These packages will be fetched from the extras repository at the given URL. Finally, it will create an ISO called My-Fedora-LiveCD-1.iso.
livecd-creator is unable to find a package -- for
example, if it's not in the specified repositories -- the command will simply skip
the package and still create the Live CD. Unless the missing package is an
essential package like the kernel, you'll still end up with a usable Live CD.
Apart from the packages mentioned in the configuration RPM, you can add custom
packages with the
--package switch. The
livecd-creator command can also use multiple repositories
to build your CD.
Listing 8. Creating a Live CD using multiple repositories
# livecd-creator --repo=c6,file:///var/www/html/repo/core \ --package=openoffice --repo=lcd6,file:///root/base_packages \ --package=fedora-livecd-gnome \ --repo=e6,http://download.fedora.redhat.com/pub/fedora/linux/extras/6/i386 \ --repo=livna,http://rpm.livna.org/fedora/6/i386 \ --package=vlc \ --fslabel=My-LiveCD-2
As in the previous example, this command creates a Live CD with all the packages from fedora-livecd-gnome. Additionally, it will include the OpenOffice.org office suite, which is available in the core repository. It will also add the VLC Media Player from the livna repository. We are calling it My-LiveCD-2, since it contains packages from third-party repositories and cannot be called a Fedora Live CD.
What if after creating the CD you want to add another application, say
Evolution e-mail client, into this custom CD? No problem. If you have the ISO of the
previous CD available, just ask
livecd-creator to use
the packages of this ISO and append the new ones.
Listing 9. Adding new packages to an existing Live CD ISO
# livecd-creator --repo=c6,file:///var/www/html/repo/core \ --base-on=My-LiveCD-2.iso --package=evolution --fslabel=My-LiveCD-New
This will create a new Live CD based on packages from the previous ISO with the additional Evolution package.
I hope the examples above show you that creating a Live CD is actually a trivial job. Using Zeuthen's packages, you can go on creating Live CDs, adding applications from any repository.
But suppose you need to create a Live CD that you can use to write documents and code as well. You'll want to include OpenOffice.org, Evolution e-mail client, Beagle desktop search, GAIM instant messenger, Xchat IRC client, GIMP image manipulator, GCC compiler, GDB debugger, and Doxygen for code documentation.
Either you can specify them with the
every time you want to assemble the CD, or you can write a configuration file of
your own. The added advantage of using a configuration file is that you can
specify your custom configuration as well.
Before you create your own configuration file, look at the configuration file that you've been using to create your Live CDs, fedora-gnome. You can extract the configuration file from the RPM by right-clicking on fedora-livecd-gnome-6-1.i386.rpm and selecting the Extract Here option. This should get you a file called 20-fedora-livecd-gnome.conf available under the etc/livecd/ directory. The prefix numbers help identify the particular package in the tree of packages. So 20-* package follows and probably depends upon a 10-* package, and a 30-* package follows and probably depends upon the 20-* and earlier packages.
The first part of the file contains a list of applications to install, and the second part contains the configuration that needs to be done for that particular environment.
Listing 10. Contents of the 20-fedora-livecd-gnome.conf file
case $1 in # inquire what packages to install; must print packages to install pkgadd) echo " chkconfig gdm gnome-panel nautilus metacity gnome-themes redhat-artwork gnome-power-manager gnome-volume-manager desktop-printing gnome-terminal gedit . . . . # run configuration scripts when all packages are installed post) # mount livecd mkdir -p /mnt/livecd mount -o ro -t iso9660 /dev/livecd /mnt/livecd # add fedora user with no passwd useradd -c "Fedora live CD" fedora passwd -d fedora > /dev/null . . . .
As you can see, most of the work such as setting up a user and setting up networking is done by the fedora-gnome package.
The best way to create a configuration file is to use the 20-fedora-livecd-gnome.conf and remove the GNOME-specific bits. Let's call our file 40-fedora-livecd-office-code.conf. This should do the trick:
# cp 20-fedora-livecd-gnome.conf
After stripping off the GNOME bits, you can add the list of packages you need. The new file should read like this (please note that I have removed the license bits to conserve space):
Listing 11. The newly created 40-fedora-live-office.conf file
#!/bin/bash # livecd configuration for Base Fedora system # PLEASE ADD LICENSE RELATED NOTE case $1 in # inquire what packages to install; prints package list on stdout pkgadd) echo " evolution evolution-connector evolution-webcal gaim xchat beagle gimp openoffice.org-core openoffice.org-draw openoffice.org-calc openoffice.org-graphicfilter openoffice.org-math openoffice.org-writer openoffice.org-xsltfilter openoffice.org-impress gcc gdb doxygen " ;; # run configuration scripts when all packages are installed post) ;; # run when an livecd install is complete to clean up install-post) ;; # run when an livecd install is complete; must prints packages to remove install-pkgrem) echo " fedora-livecd-office-code " ;; esac
Do not forget to include the name of the configuration package in the list of packages to remove before the ISO is created.
Before you can actually use this configuration file, you need to create an RPM out of it. Creating an RPM requires a SPEC file. You'll need to use Zeuthen's fedora-livecd.spec and edit it to include information about the new configuration file.
Basically, a SPEC file contains the list of files that will be included in the RPM and where will they be placed when the RPM is installed. I won't go into the details of creating a SPEC file, but you can use a SPEC file I created for this article. Download it from the Downloads section, below, and read the comments to understand the changes from Zeuthen's original file.
Note that my SPEC files points to configuration files of other packages, such as fedora-live-gnome-fedora-livecd-desktop. Make sure you have all of them available as well.
Fedora uses the
rpmbuild command to create RPMs from a
SPEC file. The
rpmbuild command expects all the .conf
configuration files to be under the /usr/src/redhat/SOURCES directory, along with
any other file mentioned as a SOURCE in the SPEC file. Also make sure the
fedora-livecd.spec file is under /usr/src/redhat/SPECS directory.
Listing 12. Creating new RPMs
# cd /usr/src/redhat/SPECS # rpmbuild -bb fedora-livecd.spec # ls /usr/src/redhat/RPMS/i386 fedora-livecd-6-2.i386.rpm fedora-livecd-gnome-6-2.i386.rpm fedora-livecd-desktop-6-2.i386.rpm fedora-livecd-office-6-2.i386.rpm
To separate the custom RPMS from the original, I've versioned them 6-2 instead of the original 6-1.
Once the RPMs are at your disposal, the procedure to create a Live CD isn't any different. Re-create the local repository of packages with the new ones.
Listing 13. Creating the local repository of configuration packages with the new RPMs
# rm /root/base_packages/* # cp /usr/src/redhat/RPMS/* /root/base_packages/ # createrepo /root/base_packages
livecd-creator to use the newly created
Listing 14. Creating a Live CD using the new Fedora-Office-Code-LiveCD RPM
# livecd-creator --repo=c6,file:///var/www/html/repo/core \ --repo=lcd6,file:///root/base_packages \ --package=fedora-livecd-office-code \ --repo=e6,http://download.fedora.redhat.com/pub/fedora/linux/extras/6/i386 \ --fslabel=My-Fedora-Office-Code-LiveCD
Presto! You have your very own custom Live CD from your very own custom configuration.
Once you get the hang of creating configuration RPMS, you'll be creating Live CDs in no time. You can customize the Live CDs by tweaking any setting and adding or removing packages. Add to that the ability to move any data file into the Live CD environment, as I've shown in my SPEC file.
It's only a matter of time before the Live CD installer, already in testing
stages, is released. One single entry in your configuration file or a
--package option will bundle it onto your Live CD, making
it fully installable on the hard disk. How cool is that? Your custom Linux
distribution in no time.
|Sample SPEC file||fedora-livecd-custom.zip||2KB||HTTP|
- The Fedora Live CD wiki is the
home page for the project.
- "Fedora releases a
live CD" (linux.com, January 2007) gives additional background on the Fedora
Live CD project.
- Read these developerWorks articles for more
information on creating Live CDs:
- "Spin up a Linux LiveCD" (developerWorks, July 2004)
- "Assess system security using a Linux LiveCD" (developerWorks, July 2005)
- "Restore compromised systems with diagnostics LiveCDs" (developerWorks, July 2005)
- "Back to school with education LiveCDs" (developerWorks, January 2006)
- "Rock your desktop with entertainment LiveCDs" (developerWorks, January 2006)
- "Linux screensaver for Windows" (developerWorks, December 2005)
- "Craft a load-balancing cluster with ClusterKnoppix" (developerWorks, December 2004)
- The One Laptop
Per Child (OLPC) project has given itself the mission of putting
learning-oriented laptop technology in the hands of children in developing
- Find more
for Linux developers
- Stay current with
technical events and webcasts.
Get products and technologies
Livna and FreshRPM
are two very popular repositories for getting unofficial third-party packages for
- You can view the list of packages available in
the "core" as
well as the "extras" repository for Fedora 6.
Get the livecd-tools RPM from Zeuthen's Fedora home
Create a local repository with the createrepo tool.
Creating an RPM requires a SPEC file. Get Zeuthen's
fedora-livecd.spec and edit it to include information about the new
Order the SEK for Linux,
a two-DVD set containing the latest IBM trial software for Linux from DB2®,
Lotus®, Rational®, Tivoli®, and WebSphere®.
IBM trial software
directly from developerWorks.
developerWorks blogs, and
get involved in the developerWorks community.
Mayank Sharma is a contributing editor at the Open Source Technology Group (OSTG), a division of VA Linux, and publishes mainly on OSTG's NewsForge and Linux.com. Also, he contributes a monthly column for Packt Publishing. In addition, he teaches courses on open source topics at the Indian Institute of Technology, Delhi, as guest lecturer.