June 20, 2008

Create minimal LiveCD on Ubuntu Hardy and live-helper

Sometimes you want a bare-minimum LiveCD that you can use as a base for other projects. Creating one on Ubuntu is a rather big pain. GUI tools like ‘Reconstructor’ or ‘Ubuntu Customization Kit’ are meant to modify the existing install/Live CD’s, and don’t allow you to really strip down the CD to the bare minimum.

Debian has a project called live-helper which allows you to do just that with a debian distribution. This is also included in Ubuntu Hardy, but it doesn’t -quite- work out of the box. However, with the following small changes, you can make it work. I’ve just create a 77MB minimal hardy boot CD, and it works like a charm.

Here’s what you need to do:

  • apt-get Install live-helper cdebootstrap
  • cdebootstrap has a bug on hardy that doesn’t look like it’ll be fixed until Intrepid gets released. To fix it, edit the file ‘/usr/share/cdebootstrap/suites’, and att the following lines to the bottom:

    Suite: hardy
    Config: generic-ubuntu
    Keyring: ubuntu-archive-keyring.gpg

    It’s pretty obvious someone just forgot to add the entry for hardy.

  • This isn’t strictly necessary, but in order to build a CD with the latest security and updates, you’ll need to modify one of the scripts. Debian appearently names their updates repository with a ‘/’ instead of a ‘-’ like Ubuntu. This means that the live-helper scripts try to access ‘hardy/updates’ instead of ‘hardy-updates’. To fix this, you need to edit the file ‘/usr/bin/lh_chroot_sources’ and change all references containing




    You should find them on lines 64, 68, 233, and 237.

  • Now you’re ready to actually use the live-helper scripts, so first, create a directory to use for scratch:

    $ mkdir ~/live && cd ~/live

  • This is the really important line. run ‘lh_config’ with the correct parameters. To create a minimal ubuntu CD, I used this command line:

    lh_config -p minimal -a i386 -d hardy –mirror-bootstrap “http://us.archive.ubuntu.com/ubuntu” –mirror-bootstrap-security “http://security.ubuntu.com/ubuntu” –mirror-binary=”http://us.archive.ubuntu.com/ubuntu” –sections “main restricted” –mirror-binary-security “http://security.ubuntu.com/ubuntu” –initramfs casper -k generic –linux-packages=”linux-image” –apt-secure disabled –bootstrap cdebootstrap

    To break this down further:

    • ‘-p minimal’ : use the minimal package set
    • ‘-a i386′ : use 32-bit packages so this will run on any 32-bit or 64-bit x86 system.
    • ‘-d hardy’ : specify the distribution to use.
    • ‘–mirror-*’ : set these up to point to the ubuntu mirrors instead of the debian ones. Note you can use local mirrors if you have 32-bit mirrors lying around. The ‘*-binary*’ entries are what the LiveCD will use, the ‘*-boostrap-*’ entries are what cdebootstrap will use to download the packages for the livecd.
    • ‘–sections “main restricted”‘ : set the allow the liveCD to grab packages from both ‘main’ and ‘restricted’. Note this leaves out universe.
    • ‘–initramfs casper’ : Use ‘casper’ instead of ‘live-initramfs’. live-initramfs doesn’t seem to work quite right on Ubuntu yet, so not setting this parameter left me with a system that booted but with no terminal prompt and thus no way to do anything.
    • ‘-k generic’ : suffix to add to ‘linux-image’ package name. ‘-generic’ gives you a standard 32/64 bit kernel.
    • ‘–linux-packages “linux-image”‘ : Debian uses ‘linux-image-2.6′, as well as includes some module packages that are included by default on Ubuntu, so you must set this.
    • ‘–bootstrap cdebootstrap’ : by default it will try and use ‘debootstrap’ which failed for me because it didn’t install gpgv by default, whereas cdebootstrap did. If omeone could make this work with debootstrap, we wouldn’t need to cdebootstrap fix above…
    • ‘–apt-secure disable’ : Actually, may not be needed, was playing around with this trying to figure out the gpgv problem up above, so this can probably be ignored.
  • Run


    and cross your fingers. With any luck, it’ll run to completion and you’ll have a nice, ~80MB ‘binary.iso’ file waiting for you in the current directory.

live-helper is actually quite powerful and quite involved. See the Manual for more information.

Posted by john under linux | Comments (26)


  1. I seem to be having a problem. I did everything exactly as above, and here is the result…

    scott@alty:~/live$ sudo lh_build
    P: Begin caching bootstrap stage...
    P: Begin bootstrapping system...
    I: Retrieving Release
    E: Failed getting release file http://ftp.debian.org/debian/dists/hardy/Release

    Comment by scott — July 11, 2008 @ 10:28 pm

  2. Now how do you modify that with your custom app which includes LAMP in my case.

    Comment by Frank — July 19, 2008 @ 12:49 pm

  3. This might be cool, but I get

    E: Failed getting release file http://ftp.debian.org/debian/dists/hardy/Release

    When I run lh_build :(

    Comment by Aztek — July 24, 2008 @ 7:27 pm

  4. Nevermind, I poked around and found the bootstrap file didn’t have the right params (even though I used your command line verbatim. maybe it didn’t like cut/paste :) )

    I manually put them in and it’s workin’!

    Comment by Aztek — July 24, 2008 @ 7:40 pm

  5. Thanks for this heads-up on the state of the Ubuntu live-helper, I found it really useful, particularly the notes on the difference between Debian and ubuntu repos that need to be accommodated. nice work!

    Comment by Bruce — July 28, 2008 @ 4:52 pm

  6. ps – if you are going to do builds for other than Ubuntu, that repo selection logic will need to be changed again, or extended – tripped me up later! :-)

    Comment by Bruce — July 28, 2008 @ 5:19 pm

  7. I can’t get this working.

    When I do sudo lh_build

    It returns an error:

    P: Begin caching bootstrap stage…
    P: Begin bootstrapping system…
    I: Retrieving Release
    E: Failed getting release file http://ftp.debian.org/debian/dists/hardy/Release

    Any Ideas???

    Comment by LuisPT — July 30, 2008 @ 5:46 pm

  8. Hi John,

    I just found your nice article about live-helper by luck. Thanks for writing it up.

    Before October 2007, we had that command-line option ‘–mode’ to specify a different defaults set (well, we still have it, but it just doesn’t recognize ubuntu as a valid mode anymore, see below). Means, one could specify e.g. –mode ubuntu and live-helper took the right ubuntu defaults and then worked out-of-the-box, not requiring the changes you’ve listed here.

    Then, I didn’t had time enough to track all ubuntu specific stuff anymore, nobody else in debian did step up to take care about it, and so I just removed ubuntu from the mode-support.

    In general, I would welcome that live-helper can also build ubuntu images, however, I don’t have the time to work on this one too. Now that I found your article, I’m wondering if you continue to use live-helper and if you would have time and be interested to take care about keeping those ubuntu defaults in the ubuntu-mode working by providing patches from time to time, to update them when it’s necessary.


    Comment by Daniel Baumann — August 25, 2008 @ 6:38 pm

  9. thanks , i hope that i can add xfce or lxde to the list of installed packages

    I want to create my custom livecd and i wish to be small and include only what is needed

    Comment by mariuz — September 1, 2008 @ 4:01 am

  10. @Frank: You can either add any packages you want to the “linux-packages” command line if you have debian packages, or you can add the files to ~/live/config/chroot_local-includes directory, and they’ll be copied into the CD. See http://alioth.debian.org/~lamby-guest/live-manual/html/contents.html#chroot-local-includes

    @Bruce: Yep, it’s a hack not a fix. I guess the proper fix would be to set a variable LH_DISTRIBUTION_DELIM=’-’ (or ‘/’) and fix it up right.

    @LouisPT: Hmm.. you and Aztek had the same issue. Obviously the mirror isn’t getting set up correctly for some reason, but I can’t say why in your case.

    @Daniel: I’ll see what I can do. I don’t have a ton of time, but I do have some. I can at least look it over and see what is involved.

    @mariuz: You’re welcome.

    Comment by john — September 2, 2008 @ 9:50 pm

  11. OK thank you for the useful tool
    the only issue i had with the parameters from your example “–” is replaced with “-”

    I will use it for firebird conference where i will present an firebird + flamerobin livecd

    Comment by mariuz — September 18, 2008 @ 5:39 pm

  12. one two minuses are replaced with one

    Comment by mariuz — September 18, 2008 @ 5:43 pm

  13. After you finish you can test it with qemu or kvm

    qemu -cdrom binary.iso -m 256

    here will be my script after i finish

    now is just an bash skeleton

    Comment by mariuz — September 18, 2008 @ 6:15 pm

  14. Yes, qemu/kvm is how I test as well, although if you’re running a desktop that has any weight to it, i’d recommend 384MB instead of 256MB, but who wants to run a heavyweight environment in this case?

    And yes, it looks like the font I chose for the wordpress theme makes one dash (‘-’) and two dashes (‘–”) impossible to distinguish. Sorry for the confusion, I’ll see if I can remedy that.

    I’ve actually been poking around some with the live-helper git repo and have some changes that I can roll in. Right now, I can build an Intrepid livecd on Intrepid using live-helper, and a hardy livecd on hardy using casper, but I can’t build a hardy livecd on intrepid (nor, I’m assuming, an intrepid on on hardy). I don’t know why yet.

    Comment by john — September 18, 2008 @ 9:04 pm

  15. Got some errors when trying to add xorg

    Calculating upgrade… Done
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    P: Configuring file /etc/kernel-img.conf
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Couldn’t find package xorg-generic

    Comment by mariuz — September 19, 2008 @ 3:57 pm

  16. @marituz: how are you including xorg? I used “-p standard-x11″ which inflated things a bit (to around 115MB) but seemed to work just fine. This installs the standard packages, not the minimal set, plus xorg and a few helpers (see /usr/share/linux-helpers/lists/standard-x11)

    I’m guessing xorg-generic is the name of a debian-only package and that’s creeping into your lists somewhere.. xorg-generic doesn’t exist on Ubuntu (at least on Intrepid), it’s just ‘xorg’.

    Comment by john — September 19, 2008 @ 4:14 pm

  17. Ok i see it know i forgot about the manual

    So i will add xfce back

    Comment by mariuz — September 19, 2008 @ 8:50 pm

  18. What versions of live-helper are you using?

    Mine doesnt understand: –sections “main restricted”

    lh_config: unrecognized option `–sections’

    and then fails with

    E: Couldn’t find package loop-aes-utils

    Comment by ajvogel — September 22, 2008 @ 9:18 am

  19. I did this using the version in the Ubuntu repositories for hardy. Which should be live-helper 1.0~a37-2.

    I’ve since both upgraded to Intrepid and I’ve been working with the live-helper git repository, hence the uncertainty.

    Comment by john — September 22, 2008 @ 11:22 am

  20. E: Failed getting release file http://ftp.debian.org/debian/dists/hardy/Release

    Happens because the double-quotes in the lh_config
    string in this web page aren’t really double quotes.
    Try copy/paste in to a file, edit the file, then
    search for “. Then replace them with ‘”‘s.

    od -c calls them “342 200 223″ characters.


    Comment by Mark C. Mason — October 4, 2008 @ 5:47 am

  21. There’s something very fishy going on with cutting and pasteing to and from this web page. Obviously I messed up at copying the command line in, because some ‘–’ became single ‘-’. And, when cutting and pasting FROM this web page, things like the double quotes and the ‘-’ get messed up as well (they’re getting translated into unicode somehow, which is not what I was expecting).

    At this point, it’s better to write the command lines by hand, using the above as a guide. Any command line arguments that are more than one letter should be preceeded by double-dashes ‘–’, and not single ones, and double quotes should be real double quotes.

    Sorry for the confusion. I’ll see what I can do to fix it.

    Comment by john — October 7, 2008 @ 2:25 pm

  22. it’s works!!!!! got a 80MB iso based on ubuntu hardy, but i was wondering if i could further strip it further down?? wat are the option avaliable for ‘-p’ beside minimal?

    Comment by SLKang — November 14, 2008 @ 12:39 am

  23. @SLKang: the ‘minimal’ package is already pretty minimal. The list of packages it installs is in the file /usr/share/live-helper/lists/minimal , beyond the standard ubuntu-minimal package (i think).

    Your best bet for trimming the size down further would be creating a chroot hook script which would do things like delete /usr/share/doc/* and /usr/man/* , but then you’re getting pretty hackish. Remember that the kernel and all it’s modules take up 20-30MB themselves, plus glibc which takes up a lot. You can selectively trim it down, but you risk breaking things.

    I think 80MB is about the best you can reasonably hope for before hitting “you-really-need-to-know-what-your-doing” territory.

    Comment by john — November 14, 2008 @ 6:01 pm

  24. Hi,

    Thanks for the info. Any idea how to include debian-installer in on the live-cd?

    When adding d-i I got:

    P: Begin installing debian-installer…
    2009-05-01 13:22:11 URL:http://archive.ubuntu.com/ubuntu//dists/hardy/main/installer-i386/current/images//cdrom/vmlinuz [1920472/1920472] -> “/home/d/ubuntu-live/cache/binary_debian-installer/http:__archive.ubuntu.com_ubuntu__dists_hardy_main_installer-i386_current_images__cdrom_vmlinuz” [1]
    2009-05-01 13:22:32 URL:http://archive.ubuntu.com/ubuntu//dists/hardy/main/installer-i386/current/images//cdrom/initrd.gz [5305592/5305592] -> “/home/d/ubuntu-live/cache/binary_debian-installer/http:__archive.ubuntu.com_ubuntu__dists_hardy_main_installer-i386_current_images__cdrom_initrd.gz” [1]
    2009-05-01 13:22:32 Fout 404: Not Found.
    E: Could not download file: http://archive.ubuntu.com/ubuntu//dists/hardy/main/installer-i386/current/images//cdrom/gtk/vmlinuz
    P: Begin unmounting filesystems…

    Comment by flower — May 1, 2009 @ 7:13 am

  25. Thank you for these instructions ! FYI, I updated them in order to work with/for Ubuntu Jaunty (9.04): http://david.decotigny.fr/wiki/wakka.php?wiki=LiveHelperUbuntu

    Comment by d2 — May 28, 2009 @ 4:02 am

  26. Good update d2!
    Is there anyone who had any luck with creating a custom USB-live and the persistent file “casper-rw”. It does work when ubuntu transfer the CD to USB. But I can not make it work when doing a custom setup for use on asb-flash.

    Comment by bebi — October 5, 2009 @ 3:38 am

RSS feed for comments on this post.

Leave a comment

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .