Building a custom Debian LiveCD

These are the steps I used to build a Debian 7 LiveCD on a Debian 7 host system. They’re based heavily on the instructions posted by Will Haley in this post.

For more details about customizing the environment, read about:

  • Syslinux – this is the suite of tools that lets you boot Linux from just about anything
  • Genisoimage – this is the ISO image creation tool, with parameters to make it bootable
  • Readyroot – a chroot management script I posted and use to manage these environments

The first think to do is setup a chroot environment. I have a generic post on the subject here. If you are following along, I’m making the following assumptions:

  • You have created /usr/src/readyroot
  • Your image is located in /usr/src/mycd_live_boot/chroot
  • Your current working directory is /usr/src/mycd_live_boot

Some other files, like the initramfs also go under mycd_live_boot, that’s why it’s in a chroot subdir.

Setup the host system

First you need to add some packages to your host system

apt-get install syslinux squashfs-tools genisoimage rsync

Customize your LiveCD

Enter the live environment

/usr/src/readyroot chroot open

Now you need to install live-boot

apt-get install live-boot

Now that’s technically all your need, but it leaves you with a fairly useless system. To add some of the packages you’ve come to expect, run:

apt-get install network-manager net-tools openssh-client ftp pciutils usbutils rsync nano

This is a good time to add whatever other tools you need. You can always re-enter the chroot and make changes.

Before you leave, it’s a good idea to cleanup with

apt-get clean

Now just exit to return to the host root, and detach it with

/usr/src/readyroot chroot close

Setting up the CD

Create two directories to contain the filesystem archives

mkdir -p image/{live,isolinux}

Copy the kernel and initrd. This is assuming you only have a single version 3 kernel.

cp chroot/boot/vmlinuz-3.* image/live/vmlinuz1 && 
cp chroot/boot/initrd.img-3.* image/live/initrd1

Create a file at image/isolinux/isolinux.cfg with this content

UI menu.c32

prompt 0
menu title Debian Live

timeout 300

label Debian Live 3.2.0-4
menu label ^Debian Live 3.2.0-4
menu default
kernel /live/vmlinuz1
append initrd=/live/initrd1 boot=live

Copy the ISO boot files

cp /usr/lib/syslinux/isolinux.bin image/isolinux/ && 
cp /usr/lib/syslinux/menu.c32 image/isolinux/

Creating the ISO

Create the SquashFS file

test -f image/live/filesystem.squashfs && 
rm -f image/live/filesystem.squashfs; 
mksquashfs chroot image/live/filesystem.squashfs -e boot

Create the ISO file

cd image && 
genisoimage -rational-rock \
    -volid "Debian Live" \
    -cache-inodes \
    -joliet \
    -full-iso9660-filenames \
    -b isolinux/isolinux.bin \
    -c isolinux/ \
    -no-emul-boot \
    -boot-load-size 4 \
    -boot-info-table \
    -output ../debian-live.iso . && 
cd ..

Now burn the ISO and you’re ready to go. It’s easier to attach it to a VM to test.


About robertlabrie
DevOps Engineer at The Network Inc in metro Atlanta. Too many interests to list here, check out my posts, or look me up on LinkedIn

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: