live-build basics: Make your own live-cd or usb-hdd

Share your wisdom. Not for support questions!

Moderator: How-to Curator

live-build basics: Make your own live-cd or usb-hdd

Postby fsmithred » February 17th, 2011, 5:04 am

Discussion: viewtopic.php?f=24&t=190

You can build your own live-cd or usb-hdd in debian with live-build, which used to be called live-helper. If you've done this before, this will be easy, but note that some of the commands and options have changed. If you've never done this before, it'll be easy, and you won't have to un-learn anything.

A lot of this howto is a rewrite and/or direct lift from previous howtos written by meandean at another forum.

Build it

# Install live-build by your favorite method. (aptitude, apt-get or synaptic are good choices)

# Create a directory for building the live image, change to that directory, and become root.
Code: Select all
mkdir live
cd live

The simplist build you can do is to issue the command, 'lb config' with no options, followed by 'lb build'. If you do that, you'll get a very minimal system in iso-hybrid format. The iso-hybrid is cool, because you can burn it to a cd or image it directly to a usb flash drive using the dd command, but it'll be a boring build. Use some config options to make it more interesting. Here are some examples.

(pick one of the following configuration examples or create your own)
Code: Select all
# example - sid with kde-core
lb config -d sid -p kde-core

# example - squeeze with gnome-core with the debian live installer
lb config -d squeeze -p gnome-core --debian-installer live

# example - sid with lxde and some extra packages
lb config -d sid -p lxde --packages "audacious geany xfe"

# example - very minimal wheezy with the debian live installer,
# and without the 486 kernel
lb config -d wheezy -p minimal --debian-installer live  --linux-flavours 686

# example - squeeze with xfce, with contib and non-free repos enabled,
# and with some extra packages
lb config -d squeeze -p xfce --archive-areas "main contrib non-free" --packages "openssh-server iceweasel flashplugin-nonfree"

# Build the image.
Code: Select all
lb build

Test it and use it

You'll end up with an iso-hybrid image file. You can test it by booting it with qemu.
Code: Select all
qemu -cdrom binary-hybrid.iso
qemu -cdrom binary.iso   (if you made a standard iso image)
qemu -drive file=binary.img   (if you made a usb-hdd image)
If you're familiar with virtualbox or vmware, you can test with those instead.

If you decide that you want to build it differently, or if it didn't work, you can start over with
Code: Select all
lb clean
lb config --whatever-config-options
lb build

Burn the image to cd using your favorite burning software or image it directly to a usb flash drive with the dd command:
Code: Select all
dd if=binary-hybrid.iso of=/dev/sdX

where X is replaced with the correct letter for your usb stick. Note that there's no partition number on that. You'll be destroying any information on the usb stick and replacing it with the new image. Take care to name the correct drive. (dmesg and 'fdisk -l' are your friends here.)

Additional notes:

If you don't want an iso-hybrid, add the -b (--binary-image) option to the 'lb config' line. Use '-b iso' for a plain old iso file, or '-b usb-hdd' for a usb-drive image. You may want to do this if you plan to edit some of the files in the image after it's built. (Not covered in this howto.)

You can rebuild the same configuration in a different binary image type without doing a complete clean, and just specifiy the binary image using the -b option.
Code: Select all
lb clean --binary
lb config -b usb-hdd
lb build

The default mirror used for the build is
To use a mirror closer to you, the easiest way is to create and edit /etc/live/build.conf with something like the following:
Code: Select all

The lines above will only affect the mirror used during the build. The image itself will use in the sources.list file, and that will automatically choose the closest mirror if you need to install any packages while you're running the live system.

Here's the list of debian mirror sites -

Customizing the user's home directory
Get the live system running, set all your preferences in your home the way you want, then copy /home/user/ of the running live system to live/config/chroot_local-includes/etc/skel/ and then build a new image.

That could be the subject of another howto. Short version:, I like to run the iso image in virtualbox, mount /home/user to the host system with sshfs, then rsync the mount to chroot_local-includes/etc/skel. But this is linux, so there are multiple ways to accomplish the same task.

Additional help:

Debian Live Manual

English, html, with table of contents

Other languages

Preconfigured package lists, called at configuration with the -p (--package-lists) option, can be found in /usr/share/live/build/lists
You can also create your own package lists. See the Debian Live Manual.
Code: Select all
debian-forensics        kde-extra
debian-live-devel       kde-full
debian-live-pxe-server  lxde
debian-science          lxde-desktop
gnome                   minimal
gnome-core              rescue
gnome-desktop           standard
gnome-full              standard-x11
kde                     xfce
kde-core                xfce-desktop

Note: The prebuilt GNOME, KDE, LXDE and XFCE images available for download at ‹› are built using the corresponding virtual *-desktop lists.

A full list of configuration options with descriptions can be found in 'man lb_config' (use the underscore to get the man page, but not to run the command.)
Code: Select all
       lb config
            [--apt apt|aptitude]
            [--apt-ftp-proxy URL]
            [--apt-http-proxy URL]
            [--apt-pdiffs true|false]
            [--apt-options OPTION|"OPTIONS"]
            [--aptitude-options OPTION|"OPTIONS"]
            [--apt-pipeline DEPTH]
            [--apt-recommends true|false]
            [--apt-secure true|false]
            [-a|--architecture ARCHITECTURE]
            [-b|--binary-images iso|iso-hybrid|net|tar|usb-hdd]
            [--binary-filesystem fat16|fat32|ext2]
            [--binary-indices true|false|none]
            [--bootappend-install PARAMETER|"PARAMETERS"]
            [--bootappend-live PARAMETER|"PARAMETERS"]
            [--bootloader grub|syslinux|yaboot]
            [--bootstrap cdebootstrap|cdebootstrap-static|debootstrap|copy]
            [--bootstrap-config FILE]
            [-f|--bootstrap-flavour minimal|standard]
            [--bootstrap-keyring PACKAGE]
            [--cache true|false]
            [--cache-indices true|false]
            [--cache-packages true|false]
            [--cache-stages STAGE|"STAGES"]
            [--checksums md5|sha1|sha256|none]
            [--build-with-chroot true|false]
            [--chroot-filesystem ext2|ext3|squashfs|plain|jffs2]
            [-c|--conffile FILE]
            [--debconf-frontend dialog|editor|noninteractive|readline]
            [--debconf-nowarnings true|false]
            [--debconf-priority low|medium|high|critical]
            [--debian-installer           true|cdrom|netinst|netboot|business‐
            [--debian-installer-distribution daily|CODENAME]
            [--debian-installer-preseedfile FILE|URL]
            [--debian-installer-gui true|false]
            [-d|--distribution CODENAME]
            [-e|--encryption false|aes128|aes192|aes256]
            [--fdisk fdisk|fdisk.dist]
            [--grub-splash FILE]
            [--gzip-options OPTION|"OPTIONS"]
            [--hooks FILE]
            [--hostname NAME]
            [--includes PATH]
            [--initramfs auto|none|live-boot|live-initramfs|casper]
            [--interactive shell]
            [--isohybrid-options OPTION|"OPTIONS"]
            [--iso-application NAME]
            [--iso-preparer NAME]
            [--iso-publisher NAME]
            [--iso-volume NAME]
            [--jffs2-eraseblock SIZE]
            [--keyring-packages PACKAGE|"PACKAGES"]
            [-l|--language LANGUAGE]
            [-k|--linux-flavours FLAVOUR|"FLAVOURS"]
            [--linux-packages "PACKAGES"]
            [--losetup losetup|losetup.orig]
            [--memtest memtest86+|memtest86|none]
            [-m|--mirror-bootstrap URL]
            [--mirror-chroot URL]
            [--mirror-chroot-security URL]
            [--mirror-chroot-volatile URL]
            [--mirror-chroot-backports URL]
            [--mirror-binary URL]
            [--mirror-binary-security URL]
            [--mirror-binary-volatile URL]
            [--mirror-binary-backports URL]
            [--mirror-debian-installer URL]
            [--mode debian|emdebian|ubuntu]
            [--net-root-filesystem nfs|cfs]
            [--net-root-mountoptions OPTIONS]
            [--net-root-path PATH]
            [--net-root-server IP|HOSTNAME]
            [--net-cow-filesystem nfs|cfs]
            [--net-cow-mountoptions OPTIONS]
            [--net-cow-path PATH]
            [--net-cow-server IP|HOSTNAME]
            [--net-tarball bzip2|gzip|tar|none]
            [-p|--packages-lists LIST|"LISTS"]
            [--packages PACKAGE|"PACKAGES"]
            [-r|--repositories REPOSITORY|"REPOSITORIES"]
            [--root-command sudo]
            [--use-fakeroot true|false]
            [--archive-areas ARCHIVE_AREA|"ARCHIVE_AREAS"]
            [--security true|false]
            [--source true|false]
            [-s|--source-images iso|net|tar|usb-hdd]
            [--symlinks true|false]
            [--syslinux-splash FILE]
            [--syslinux-timeout SECONDS]
            [--syslinux-menu true|false]
            [--sysvinit true|false]
            [--tasksel aptitude|tasksel]
            [--tasks TASK|"TASKS"]
            [--templates PATH]
            [--virtual-root-size MB]
            [--volatile true|false]
            [--backports true|false]
            [--exposed-root true|false]
            [--username NAME]
            [--win32-loader true|false]

Posts: 214
Joined: February 11th, 2011, 4:14 am

Return to HowTo

Who is online

Users browsing this forum: No registered users and 1 guest