Created at:

Modified at:

Debian Automated Install

Introduction

Automated install for computer systems is a concern common to many developers and sysadmins. Making a workable automated install can be painful and yield a totally non-flexible system, but it has its good side, too. It:

There are several tools that can help on a automated installation of Debian GNU/Linux. Most of them are cited in the pages below.

Automatic Installation

Debian GNU/Linux Installation Guide

In this guide, we will stick with "preseed", an automation tool built-in in the Debian CD. A good guide about how to use this tool can be found here:

Automating the installation using preseeding

That might be useful to check the "Other References" at the end of this page for other useful resources not listed along the text.

Overview

*Note*: This were made with a installation CD of Debian GNU/Linux 5.0 (Lenny).

Pressed is already built-in on Debian CD. It basically runs the installer but, instead of asking questions to the user, it fills the answers with the contents of a configuration file (so its name). With a normal Debian CD, the path of this file can be passed at the boot time. Just follow these instructions:

1. Boot from the Debian CD 2. Chose the Automated Install under the Advanced menu. 3. Type <TAB>, in order to fall to the boot prompt. 4. Append this words: preseed/url=http://where.your.file.is/preseed.cfg.

See section "Contents of preseed.cfg" for its contents.

In my case, I was unable to get the file from the network because this computer lacked a network connection, so we are getting it from the CD itself. In order to make that, we need to remaster the Debian CD.

Remastering the CD

Pages below are useful, but I found them (at the time of this writing) a bit difficult and confusing. Anyway they might be good references.

Debian-Installer: How to modify an existing CD image

Preseeding d-i

Debian-Installer: Building images with a custom kernel

The remastering of a Debian CD can be made by an ordinary Debian CD. Just download the installation CD and extracts its ISO image. A very good guide on how to do that is described in "Linux Boot Media" page.

Linux Boot Media

First, mount the Debian ISO::

    # mount -o loop -t iso9660 debian-503-i386-CD-1.iso /mnt/iso

Then, in summary, the following steps are enough to extract the CD::

    # mkdir newcd
    # cp -pr /mnt/iso/install.386 newcd/
    # cp -pr /mnt/iso/isolinux newcd/
    # # payload
    # cp -pr /mnt/iso/.disk newcd/
    # cp -pr /mnt/iso/pool newcd/
    # cp -pr /mnt/iso/dists newcd/
    # cd newcd && ln -s . debian

These directories are enough.

After copying the files of the ISO to a folder where you can modify them (as described in the page just cited).

There you can modify any file you want, like the isolinux/isolinux.cfg file in order to customize the Debian boot menu. After making the modifications, just remake the ISO with the following command::

    # mkisofs -o ../custom_install.iso -r -J -no-emul-boot -boot-load-size 4 \
        -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat .

Now, custom_install.iso is our remastered CD.

Inserting other packages besides the default ones

As told in the "Debian-Installer: How to modify an existing CD image" page, to insert other packages that not the default in a Debian CD, just create a directory in pool/main and put your packages there.

Putting the packages there is not enough, since we need to update all indices that refer to the packages. To make that, we will create a file named, in this example, /tmp/config-deb, with the following content::

    Dir {
       ArchiveDir "newcd";
       OverrideDir "indices";
       CacheDir "indices";
    };

    TreeDefault {
       Directory "pool/";
    };

    BinDirectory "pool/main" {
       Packages "dists/lenny/main/binary-i386/Packages";
       BinOverride "override";
       ExtraOverride "override.extra";
    };

    Default {
       Packages {
           Extensions ".deb";
       };
    };

ArchiveDir points to where the unpacked Debian CD is. In this example newcd is relative and it is at the same directory we are running apt-ftparchive. indices is a directory (at the same path) that has a override file.

Then, execute the this command::

    apt-ftparchive generate config-deb

It just recreated packages indices in dists/lenny/main/binary-i386/Packages. We also need to recreate the dists/lenny/Release file. To do that, create a file with this content::

    APT::FTPArchive::Release::Codename "lenny";
    APT::FTPArchive::Release::Origin "Debian";
    APT::FTPArchive::Release::Components "main";
    APT::FTPArchive::Release::Label "Debian";
    APT::FTPArchive::Release::Architectures "i386";
    APT::FTPArchive::Release::Suite "testing";

And run this command::

    apt-ftparchive -c config-rel release newcd/dists/lenny > newcd/dists/lenny/Release

Also, it will be necessary to recreate the md5 index. So, after cd'ing to the extracted ISO root, run this command::

    md5sum `find ! -name "md5sum.txt" ! -path "./isolinux/*" -follow -type f` > md5sum.txt

This will replace the md5sum.txt file with a new one, which has the newer packages included.

isolinux/isolinux.cfg

This file has the configuration to draw the boot menu. If you don't want to edit the boot parameters manually to load the preseed file whenever you do an automatic installation, create a new entry in this file or in the ones it includes.

Preseed hooks

TODO

Contents of preseed.cfg

TODO

initrd edition

(2010-06-01)

That shouldn't be necessary to edit the initrd.gz file. But if you need to, use these commands:

To unpack it::

cd <somewhere>

mkdir initrd

cd initrd

gunzip -c <initrd.gz-location> | cpio -i

To pack it back::

find . | cpio -o -H newc | gzip > <initrd.gz-location>

Other References