Wednesday, April 1, 2009

Howto build Debian Live CD

Generating a Debian Live CD is very simple. You need to have live-helper (package available in Debian sid and lenny), and Debootstrap (or cdebootstrap) from etch or newer.

1. Install live-helper

Install live-helper.

apt-get install live-helper

2. Configure the current working directory with lh_config

lh_config -b iso -a $ARCH

where $ARCH is the intended architeture (i.e. - i386 or amd64).

-b flag is used to be sure to obtain image in ISO format.

2. Build the image with lh_build

Execute lh_build as root:


The command above will create the basic image, containing just the Debian standard system (with no X at all).

If you want to have any of the Desktop_environments on your livecd, ls /usr/share/live-helper/lists will show a number of available package Lists to choose from, e.g. lh_config -p gnome-desktop.

More examples are listed at DebianLive/Examples.

See DebianLive/Configuration for help configuring a local Debian Mirror and other aspects of the live system.

3. Test the image

If you have qemu installed, you can boot the image with:

qemu -cdrom binary.iso
If you have also kqemu installed, you can add -kernel-kqemu.

Examples for generating a Debian Live CDs and others.

This page is really intended to be for command line examples of live-helper. This page assumes you have live-helper installed. Many of the basic examples are also in the man pages. As always, please look at the man page to understand more about the listed examples and other options offered.

See also DebianLive/BuildingImages for alternate ways to build images which can be combined with the examples shown below to give you finer control over the build process as needed.

0. Prepare your working directory and become root

Start by creating a working directory where live-helper will create the image file and also the config, cache, chroot and binary directories. Remember to execute lh_build in this working directory as root. If you prefer, use sudo instead of su (e.g. lh_config && sudo lh_build) for all of the following examples.

mkdir debian-live
cd debian-live

1. Basic lh_build examples

The lh_config helper accepts a number of command-line switches to generate a configuration for different kinds of images.

To build a basic image with default settings, run this:

lh_config && lh_build

To generate the a kde desktop image:

lh_config -p kde-desktop && lh_build

To generate a gnome desktop image:

lh_config -p gnome-desktop && lh_build

To generate an xfce desktop image:

lh_config -p xfce-desktop && lh_build

To make live CDs of specific architectures:

lh_config -a i386 && lh_build
lh_config -a amd64 && lh_build

To make live CDs of different distributions (default is etch):

lh_config -d lenny && lh_build
lh_config -d sid && lh_build

2. More complex lh_config examples

Gnome with audacity:

lh_config -a i386 --categories "main contrib non-free" -p gnome --packages audacity && lh_build

Make a netboot for network booting servers:

lh_config -a i386 -d etch -t net && lh_build

Make a live CD with custom files injected into the image:

  • First, create the configuration directory:

  • Second, copy or symlink all the files from /some/path/to/my_includes/usr/bin to /target/directory/config/chroot_local-includes/some/path/to/my_includes. These files will be automatically copied into the live system.
  • Finally, build:


Make a live CD with unofficial debian packages installed into the image:

  • If you have local debian packages (*.deb) which are not part of a repository, after running lh_config, copy them into config/chroot_local-packages and they will be automatically installed into the live system when you run lh_build.
  • If you want to install packages from an unofficial/third-party Debian repository, add the source.list entry into config/chroot_sources/sources.list.bootstrap and config/chroot_sources/sources.list.binary, and specify the packages either with a local package list in config/chroot_local-packageslists or with the --packages parameter. For more information, read the examples in /usr/share/live-helper/examples/sources/.

Make one live CD with some hooks

  • If you have all the hacks in one script just copy it to the chroot_local-hooks directory:

cp script config/chroot_local-hooks
  • If you want to chroot and do the hacks, either set LH_INTERACTIVE to enabled, or run:

lh_chroot_hosts install
lh_chroot_resolv install
lh_chroot_proc install
chroot chroot
#do the hacks here
lh_chroot_hosts remove
lh_chroot_resolv remove
lh_chroot_proc remove

  • If you have one good CD but you need to change something:

lh_clean --binary
# change what you need in the chroot directory or follow the last note about making some hacks
This assumes your bootstrap stage is still intact from previous calls to lh_bootstrap (or lh_build)

A brief guide to burn "a Debian Live CD" on a CD-ROM:

If you want to generate a custom Debian live CD, including only the tools you want (and maybe additional tools you don't find in other live CDs) there's a really simple solution: live-helper.

Creating a basic bootable Debian live CD ISO image in the current directory is as simple as:

  $ lh_config
$ lh_build

That's it. The result will be a file called binary.iso, which you can either burn on a CD-ROM via

  $ wodim binary.iso

or test in QEMU using a command line like this:

  $ qemu -boot d -cdrom binary.iso

Of course there are many possibilities to customize the generated image to your likings, see the documentation in the Debian wiki, or the lh_config/lh_build manpages.

Please note that live-helper can not only generate CD ISOs, but also bootable DVDs, images for USB thumb drives, or netboot images.

There's also a nice GUI called live-magic which will make the process a bit easier if you don't like doing things on the command line.

No comments: