InstallCDCustomizationHowTo

Differences between revisions 21 and 22
Revision 21 as of 2005-12-22 11:46:56
Size: 14869
Editor: 83-216-156-196
Comment: line-wrapping
Revision 22 as of 2005-12-22 11:48:16
Size: 14870
Editor: 83-216-156-196
Comment: more typos etc.
Deletions are marked like this. Additions are marked like this.
Line 181: Line 181:
# dpkg-buildpackage rfakeroot -m"My Name <my.email@my.hosts>" # dpkg-buildpackage -rfakeroot -m"My Name <my.email@my.hosts>"
Line 188: Line 188:
# Original = $ORIG: location of the "clean", unmodified cd .iso
# CD mount point = $MOUNT: mount point of clean cd
# Original = $ORIG: location of the "clean", unmodified CD .iso
# CD mount point = $MOUNT: mount point of clean CD
Line 221: Line 221:
# the top-level Release file, and top-level  Release.gpg.
# everything else should be in your $STAGE filestructure or usable unchanged
# the top-level Release file, and top-level Release.gpg.
# everything else should be in your $STAGE file structure or usable unchanged

CD Customization

The process of customizing or "remastering" Ubuntu CDs is not especially 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 three main parts: a bootloader (ISOLINUX on amd64/i386 systems, yaboot on powerpc) and its configuration, which start everything up; debian-installer (d-i) which in this case is really a specialised miniature Ubuntu system; and a Debian-style repository structure, which is what takes up all that space on the disk in the directories "pool" and "dists". Building a new CD may involve modifications to all three 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 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 identify your preseed

First, though, you need to tell d-i 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 d-i where to find this file by modifying the bootloader config file, located in isolinux/isolinux.cfg, to pass appropriate parameters on the kernel command line. 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 is the kernel loaded when I just press "enter" at the boot prompt. APPEND contains the options passed to the kernel. preseed/file is the most important one; the next two identify my locale 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 ~t^ubuntu-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

(Note that the version of this file on breezy CD images was buggy: it set base-config/package-selection to "~tubuntu-standard" rather than "~t^ubuntu-standard$". Use the new version in preference; the old one will break with Ubuntu 6.04.)

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.ubuntu.com/ubuntu/dists/breezy/main/installer-i386/current/doc/manual/en/apcs01.html]. If you can't find what you're looking for, try executing the 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/package-selection" directive in the preseed. This should be set to an aptitude pattern; see the aptitude documentation for more information on these. For instance, to install an SSH server along with the standard installation, use this line:

base-config base-config/package-selection string ~t^ubuntu-standard$|~t^ubuntu-desktop$|~n^openssh-server$

To install support for additional languages, a different mechanism is available, namely to preseed the detailed locale question asked by the installer in expert mode. See the first column of /usr/share/i18n/SUPPORTED for the locale names you can use here. For example, to add support for Bengali and Tamil, use this line:

d-i localechooser/supported-locales multiselect ba_IN, ta_IN

Modify pool structure to include/delete packages

Probably the main reason to build your own install CDs 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 containing 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 the Debian package management system expects to see when it encounters a repository; generate the top-level Release file the Debian package management system expects; and sign 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 against the 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 convert to python
# & add a simple 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 relies on the existence of several files and directories:

# Original = $ORIG: location of the "clean", 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 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 \
#   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 file structure or usable unchanged 
# in the original form

# remove Release file otherwise you'll have trouble writing to it.  
sudo rm $BUILD/dists/breezy/Release*
# ubuntu-keyring must be included in main/, so main NEEDS to be rebuilt!
for component in main extras; do
    sudo apt-ftparchive packages "$BUILD/pool/$component/" > "$BUILD/dists/breezy/$component/binary-i386/Packages"
    gzip -c "$BUILD/dists/breezy/$component/binary-i386/Packages" | \
        sudo tee "$BUILD/dists/breezy/$component/binary-i386/Packages.gz" > /dev/null
done
sudo apt-ftparchive -c $APTCONF release $BUILD/dists/breezy > $BUILD/dists/breezy/Release
# gpg options: -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

InstallCDCustomizationHowTo (last edited 2008-08-06 16:17:08 by localhost)