InstallCDCustomizationHowTo

Revision 10 as of 2005-11-25 07:25:26

Clear message

CD Customization

The process of customizing or "remastering" ubuntu cd's is not espcially complex, but it is a little tedious and finicky. My knowledge of the process is also imperfect so hopefully other people will modify this page as appropriate.

The install cd has two main parts: an IsoLinux-derived OperatingSystem, which is the environment in which DebianInstaller runs; and a DebianRepository structure, which is what takes up all that space on the disk in the directories "pool" and "dists". Building a new CD involves modifications to both parts.

Modify installer behaviour using a Preseed file

When the CD boots up, a linux kernel is started and the installation tasks are initiated. The installer's default behaviour can be modified through the use of a "preseed" file, which feeds DebianInstaller ("d-i") answers to questions normally asked by debconf or in other contexts. If you look closely at your install cd, you'll see that certain options (e.g. "server", "expert", "oem") already have preseed files assigned to them.

So, suppose you are installing breezy on a bunch of identical computers and you already know the answers to certain questions (what country and time zone you're in, what keyboard you have, how the network should be configured, how you want to partition the hard disk, etc. etc.). You can "preseed" the answers to these questions in a very simple configuration file.

Changing isolinux.cfg to idnetify your preseed

First, though, you need to tell the kernel to look for your preseed file in the right place. The standard disk contains a directory /preseed; you should put your seed file there. You tell the isolinux kernel where to find this file by modifying its config file, located in isolinux/isolinux.cfg. My file has the following lines in it:

DEFAULT /install/vmlinuz
APPEND   preseed/file=/cdrom/preseed/learnexchange.seed kbd-chooser/method=us debian-installer/locale=en_CA vga=normal initrd=/install/initrd.gz ramdisk_size=16384 root=/dev/rd/0 DEBCONF_PRIORITY=critical debconf/priority=critical rw --

DEFAULT isthe kernel loaded when I just press "enter" atthe boot prompt. APPEND contains the options passed to the kernel. preseed/file is the most important one; the next two identify my local and keyboard as Canadian; DEBCONF_PRIORITY ensures I don't see any unnecessary debconf questions.

Look carefully at your file and modify as you see fit.

Writing the preseed file

There are lots of example preseed files kicking around; here's one from the cd -- server.seed:

# Don't install usplash.
d-i     base-installer/kernel/linux/extra-packages-2.6  string
# Desktop system not installed; don't waste time and disk space copying it.
d-i     archive-copier/desktop-task     string ubuntu-standard
d-i     archive-copier/ship-task        string
# Only install the standard system and language packs in the second stage.
base-config     base-config/package-selection   string ~tubuntu-standard
base-config     base-config/language-pack-patterns      string language-pack-$LL
# No language support packages.
base-config     base-config/install-language-support    boolean false

first notice the format. There are 4 fields:

  1. identity of the program which will pick up this command
  2. name of the variable whose value will be passed
  3. variable type
  4. value of variable

two important notes: currently, d-i expects there to be exactly one space between variable type and variable value; and the version of d-i used in breezy does not allow lines to be broken by the '\' character (newer versions do allow this).

I recommend starting with someone else' s preseed file and modifying it -- there's one available at http://archive.ubuntulinux.org/ubuntu/dists/breezy/main/installer-i386/current/doc/manual/en/apcs01.html. If you can't find what you're looking for, try executinghte following commands:

debconf-get-selections --installer > somefile.txt
debconf-get-selections >> somefile.txt

This will output a list of all debconf options you've chosen throughout your install; the file will be pretty long and not really suitable for inclusion on an install disk. in particular, NOTE: debconf-get-selections prints 2 spaces between variable type and variable value. You'll need to change that before putting such a file on a disk.

If you want to instruct d-i to install extra packages, or to install only a minimal set you need to change the "base-config base-config/package-selection " directive in the preseed. I wanted to add support for Bengali and tamil, so I used this line:

base-config  base-config/package-selection      string ~tubuntu-standard|~tubuntu-desktop|language-pack-gnome-bn|language-support-bn|language-pack-bn|language-support-bn|language-support-ta|language-pack-ta|language-pack-gnome-ta

Modify pool structure to include/delete packages

Probably the main reason to build your own install cd's is to modify which packages are installed; in particular you may want to add some packages to the CD. There are several ways to do this, none of which I understand fully. The easiest thing to do is to build a minimal repository structure contianing only your own extra .debs, and merge these into the cd file hierarchy before rebuilding the iso image. The tricky parts here are: generate the Packages files that debian expects to see when it encounters a repository; generate the top-level Release file debian expects; and sing the release file with gpg. Here's what I did.

  • . designate a file directory as your staging area; in that directory,

mkdir -p dists/breezy/extras/binary-i386 pool/extras/ isolinux preseed

Put your modified isolinux.cfg in isolinux/, and your preseed file in preseed/.

  • . put all the extra debs you need on your cd into pool/extras/. You will also need to include a new version of ubuntu-keyring, which I'll explain about in a second.
  • . in a text editor or some other way make a new file dists/breezy/extras/binary-i386/Release with the following content:

Archive: breezy
Version: 5.10
Component: extras
Origin: Ubuntu
Label: Ubuntu
Architecture: i386
  • . merge your changes into the cd thusly:
    1. mount your "clean" downloaded iso: mount /path/to/iso /some/mountpoint/ -o loop

      b. copy all the files to a directory somewhere (you'll need a gigabyte or two off space); I use rsync: sudo rsync -azvb --delete --backup-dir=/yeowe/usr/cdbuilder/old/ $MOUNT $BUILD (where $MOUNT isthe mountpoint, $BUILD is the location of the extracted contents)

      c. This is important. In just a minute we will generate the packages file and the top-level release file using the apt-ftparchive tool. Then we will need to sign the release file using a gpg key. The install system will then check the signature againstthe public keys held in the package ubuntu-keyring. But your signature isn't in that keyring. SO you need to make a new version of the ubuntu-keyring package. This is actually really easy, but it took me forever to do it right. So here's the necessary code:

      apt-get source ubuntu-keyring
      cd ubuntu-keyring--2005.01.11/keyring
      gpg --import < ubuntu-archive-keyring.gpg
      gpg --list-keys "Your Name"
      gpg --export  FBB75451 437D05B5 YOURKEYID > ubuntu-archive-keyring.gpg
      cd ..
      dpkg-buildpackage -rfakeroot -m"Your Name <your.email@your.host>
      cp ubuntu-keyring*deb $BUILD/pool/extras/
      ok -- what we've done here is import the 2 ubuntu keys into your main keyring, then exported them along with your own key into a replacement keyring. "YOURKEYID" should be replaced with the 8-digit hexadecimal code that gpg tells you when you do the --list-keys command above. And really, the best policy would be to do all that first, and copy a version into your $STAGE file structure so that you have it permanently available.
  • . Now use apt-ftparchive to make the Packages and Release files:
    • {{{sudo apt-ftparchive packages $BUILD/pool/extras/ > $BUILD/dists/breezy/extras/binary-i386/Packages

sudo apt-ftparchive -c $APTCONF release $BUILD/dists/breezy > $BUILD/dists/breezy/Release }}}

  • apt-conf is a file somewhere that looks about like this:

{{{APT::FTPArchive::Release::Origin "Ubuntu"; APT::FTPArchive::Release::Label "Ubuntu"; APT::FTPArchive::Release::Suite "breezy"; APT::FTPArchive::Release::Version "5.10"; APT::FTPArchive::Release::Codename "breezy"; APT::FTPArchive::Release::Architectures "i386"; APT::FTPArchive::Release::Components "main restricted extras"; APT::FTPArchive::Release::Description "Ubuntu Breezy"; }}}

  1. sign the Release file with gpg: sudo gpg --output $BUILD/dists/breezy/Release.gpg -ba $BUILD/dists/breezy/Release

  • . now you can build the iso file:

sudo mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-moved -o $IMAGE -R $BUILD/

  • $IMAGE is just the location of your iso image.
  • . finally, burn your cd using cdrecord:

sudo nice -18 cdrecord dev=ATA:1,1,0 speed=12 --blank=fast -v -gracetime=2 -tao $IMAGE that will burn the image on the second cd drive; if your cd-burner is the first or only cd-drive, change dev argument to ATA:1,0,0. I strongly recommend using rewritable media -- I've burned a LOT of coasters on this project.

OK, that should do it! If anyone's interested, I've written a little script (very simple) to mostly-automate this process. I'll just include it here I guess:

# usage 
# update-learningexchange.sh kubuntu|ubuntu|xubuntu

# a very primitive script with no structure of controls etc
# no default behaviour, etc etc
# all ofthis should be trivial to implement but my 
# bash syntax sucks
# obvious thing to do would be to conver to python 
# & add a simplre gtk front end too
# but I'm rushed at the moment

# Notes;Bugs:
# REMEMBER: this absolutely will not work if you haven't built a new version of ubuntu-keyring 
# package & included that in $STAGE/pool/extras/!  You do that thusly:
# apt-get source ubuntu-keyring
# cd ubuntu-keyring-version-info/keyring
# gpg --import < ubuntu-server-keyring.gpg
# gpg --output=ubuntu-server-keyring.gpg --export "ubuntu" "Your Name"
# dpkg-buildpackage rfakeroot -m"My Name <my.email@my.hosts>"
# cp ../ubuntu-keyring*deb $BUILD/pool/extras/


# VARIABLES
# this script reles on the existence of several files and directories:

# Original = $ORIG: location of the "claean", unmodified cd .iso
# CD mount point = $MOUNT: mount point of clean cd
# Staging area = $STAGE: where you keep all your files
#   this area should include main dirs isolinux/, pool/, and dists/ at a minimum
#   as written the script assumes you have a directory pool/extras with your 
#   extra debs, and that dists/breezy/extras/binary-i386/Release exists (copy it over from 
#   from dists/breezy/main/binary-i386, and replace "main" with "extras")
#   There is no doubt a better way to do this but it involves work...
# Building Area = $BUILD : location where your changes are merged into the "clean" directory s\
#   structure.
# Image location = $IMAGE: name of the new .iso file you want to build
# apt.conf file = $APTCONF: location of the file used to feed instructions to apt-ftparchive

ORIG="/var/www/jigdo/"$1"-breezy-install-i386.iso"
STAGE=/home/matt/LearningExchangeCD/$1/
MOUNT=/mnt/iso/
BUILD=/yeowe/usr/cdbuilder/$1
IMAGE="/yeowe/usr/cdbuilder/"$1"-learningexchange.iso"
APTCONF=/home/matt/LearningExchangeCD/apt.conf 


# sync with latest image
sudo umount $MOUNT
sudo mount $ORIG $MOUNT -o loop
# sudo rsync -azvb --delete --exclude="language-pack*" --backup-dir=/yeowe/usr/cdbuilder/old/ $MOUNT $BUILD
sudo rsync -azvb --delete  $MOUNT $BUILD
# now get rid of the old ubuntu-keyring package
sudo rm -r $BUILD/pool/u/ubuntu-keyring/
# note I've excluded a few files, shouldn't matter much for you I reckon
sudo rsync -avzb --exclude='*~' --exclude='INSTRUCTIONS.txt' --backup-dir=/yeowe/usr/cdbuilder/old/ --exclude='example-preseed.txt' $STAGE $BUILD

# generate Packages, Release, Release.gpg
# first thing to realize is, that we only need to generate the Packages files,
# the top-level Release file, and top-level  Release.gpg.  
# everything else should be in your $STAGE filestructure or usable unchanged 
# in the original form

# remove Release file otherwise you'll have trouble writing to it.  
sudo rm $BUILD/dists/breezy/Release*
# ubntu-keyring must be included in main/, so main NEEDS to be rebuilt!
# Need a for loop, "for x in [main,extras], do:".  
sudo apt-ftparchive packages  $BUILD/pool/main/ > $BUILD/dists/breezy/main/binary-i386/Packages
sudo apt-ftparchive packages  $BUILD/pool/extras/ > $BUILD/dists/breezy/extras/binary-i386/Packages
sudo apt-ftparchive -c $APTCONF release $BUILD/dists/breezy > $BUILD/dists/breezy/Release
# gpg optopns: -ba = armored, detached-sig
sudo gpg --output $BUILD/dists/breezy/Release.gpg -ba $BUILD/dists/breezy/Release

# build the actual image.  Note the options to mkisofs, which make the image bootable
sudo chown -R root:root $BUILD/isolinux  $BUILD/preseed 
sudo mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-moved -o $IMAGE -R $BUILD/

# burn the image to 2nd cd drive on most setups
sudo nice -18 cdrecord dev=ATA:1,1,0 speed=12 --blank=fast -v -gracetime=2 -tao $IMAGE

Example

xxx

Display

xxx