June 21, 2008

deb-${arch} trick.

Never knew this, but I was configuring apt-mirror to set up a ubuntu mirror and it dawned on me that I needed both amd64 and i386 binaries. In apt-mirror’s config file, there’s a ’set defaultarch’ option to mirror a different arch then what your machine is currently, but that won’t help mirroring more then one arch in the same repository.

The answer gleaned from the comments of this blog post is to append the arch to extra deb lines in the mirror.list file. I.e. to mirror both amd64 and i386, you add these lines to /etc/apt/mirror.conf:

deb-i386 http://us.archive.ubuntu.com/ubuntu hardy main restricted universe
deb-amd64 htp://us.archive.ubuntu.com/ubuntu hardy main restricted universe

If you think about it, it then makes sense why the source lines start with ‘deb-src’. Huh. Learn something new every day.

Posted by john under linux | Comments (0)

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

    ${LH_DISTRIBUTION}/updates

    to

    ${LH_DISTRIBUTION}-updates

    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

    lh_build

    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 (25)